Hi,
I am trying to use JavaScript to set the 'disabled' property of a form field. The field should be disabled if a certain value is selected from another field. Here is what I have:
It looks simple enough, but Firebug throws: "enableFields is not defined"
I am trying to use JavaScript to set the 'disabled' property of a form field. The field should be disabled if a certain value is selected from another field. Here is what I have:
Code:
<html>
<head>
<title>Test Form</title>
<script language='text/javascript'>
function enableFields() {
if(document.submit.status0.value=2) {
document.submit.field0.disabled=false;
document.submit.field1.disabled=false;
} else {
document.submit.field0.disabled=true;
document.submit.field1.disabled=true;
}
}
</script>
</head>
<body>
<form name='submit' method='post' action='something.htm'>
<select name='status0' onchange='enableFields()'>
<option value = '1'>Disabled</option>
<option value = '2'>Enabled</option>
</select>
<select name = 'field0' disabled='true'>
<option value = '1'>First option</option>
<option value = '2'>Second option</option>
</select>
<select name = 'field1' disabled='true'>
<option value = '1'>First option</option>
<option value = '2'>Second option</option>
</select>
</form>
</body>
</html>
It looks simple enough, but Firebug throws: "enableFields is not defined"