Originariamente inviato da GoldEmish
Ciao, volevo sapere come si può nascondere alcuni elementi di un form al variare del valore di un checkbox.
In pratica ho un checkbox che quando viene spuntato dovrebbe farmi apparire due textbox.
E' possibile?
E se invece volessi disabilitarli?
Come si fa a cambiare una porzione di testo (ad esempio un'etichetta del form) sempre con js?
Grazie mille!
codice:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Documento senza titolo</title>
<style type="text/css">
<!--
.CampoBlok {
font-size: 12px;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-style: normal;
font-weight: normal;
font-variant: normal;
color: #0A0000;
text-decoration: none;
visibility: hidden;
}
-->
</style>
</head>
<body>
<form action="" method="post" name="theform" id="theform">
<table width="100%" border="0" cellspacing="1" cellpadding="0">
<tr>
<td width="16%" id="Text"></td>
<td width="19%"><select name="Selez" disabled="disabled" class="CampoBlok" id="Selez">
<option value="0" selected>Seleziona</option>
<option value="1">Voce1</option>
<option value="2">Voce2</option>
</select></td>
<td width="65%"><input name="visualizzaSelezione" type="checkbox" id="visualizzaSelezione" value="true" onClick="if(this.checked){document.getElementById('Text').innerHTML='tuo messaggio';document.getElementById('Selez').style.visibility='visible';document.theform.Selez.disabled=false;}else{document.getElementById('Text').innerHTML='';document.getElementById('Selez').style.visibility='hidden';document.theform.Selez.disabled=true;}"></td>
</tr>
</table>
</form>
</body>
</html>
Questo dovrebbe fare tutto quello che vuoi.
Ciao