Forum Moderators: open
I have searched the forum but could not find a post on how to test the value of an html input checkbox (test if its checked) in order to show/hide a related text field. I hope someone can help.
Here's my half baked attempt...
<script type="text/javascript">function showhide(textfield, checkbox) {
if (document.getElementById(checkbox).value == 'yes') {
document.getElementById(textfield).style.display = 'block';
}else{
document.getElementById(textfield).style.display = 'none';
}
}</script>
<body>
<div id="part01">
<input name="ckbox" type="checkbox" id="ckbox" value="yes" onclick="showhide('txfield', 'ckbox')" />
<input name="txfield" type="file" id="txfield" size="33" style="display:none;" />
</div>
</body>
Will this work?