PDA

View Full Version : Checkbox and text box


mattih5
07-18-2005, 05:57 PM
Hi,

Could anyone help me with the following idea. I have a section of a form which requires the user to either keep a checkbox checked (checked by default) or uncheck it and enter their own value in a free text field.

If you user decides to keep the default setting (checked), then a secondary text field is disabled. However, if they wish to uncheck the box, the text box gets focus and they are invited to enter text.

Thanks in advance

hourang
07-18-2005, 06:33 PM
function checkme(){
if (document.frmName.chkBox.checked){
document.frmName.txtField.disabled = false;
document.frmName.txtField.focus();
}
else {
document.frmName.txtField.disabled = true;
}
}

<form name="frmName" method="POST" action="">
<input type="checkbox" name="chkBox" onClick="checkme();" checked>
<input type="text" name="txtField" value="">

</form>

i think thats about it :D