i have found the following code and altered it to disable certain fields in my form.
but it does not swap the fields around from disabled to enabled and visa versa.
what am i doing wrong?
the following javascript code is in a file and i use the <link... > method within the <head> tags to include this script
Code:
function txtDisable( theForm ){
cBox = theForm.NAME;
if( cBox.options[cBox.selectedIndex].value == "st" )
theForm.INP1.disabled = true;
theForm.INP1.value = "";
theForm.INP2.disabled = false;
theForm.INP2.value = "";
else
theForm.INP1.disabled = false;
theForm.INP1.value = "";
theForm.INP2.disabled = true;
theForm.INP2.value = "";
}
Code:
<form action="" method="post" enctype="multipart/form-data" name="edit">
<select name="NAME" onChange="txtDisable( this.form );">
<option value="SELECT AN OPTION">SELECT AN OPTION</option>
<option value="st">NOT READY YET</option>
</select>
<input name="INP1" type="text" size="50">
<input name="INP2" type="text" size="50" disabled>
</form>