Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
function enableDisable(oSel, n1, n2){
var disable = oSel.options.selectedIndex!=n1&&oSel.options.selectedIndex!=n2;
var arglen = arguments.length;
var obj, startIndex = 3;
var frm = oSel.form;
for (var i=startIndex;i<arglen;i++){
obj = frm.elements[arguments[i]];
if (typeof obj=="object"){
if (document.layers) {
if (disable){
obj.onfocus=new Function("this.blur()");
if (obj.type=="text") obj.onchange=new Function("this.value=this.defaultValue");
}
else {
obj.onfocus=new Function("return");
if (obj.type=="text") obj.onchange=new Function("return");
}
}
else obj.disabled=disable;
}
}
}
</script>
</head>
<body>
<form action="#" name="example1">
<div>
<select name="control1" onchange="enableDisable(this, 1, 2, 'day','month','year','hour','min')">
<option value="">No</option>
<option value="">Yes</option>
<option value="">Maybe</option>
<option value="">Absolutely Not!</option>
</select>
<br>
<input disabled type="text" name="day">
<input disabled type="text" name="month">
<input disabled type="text" name="year">
<input disabled type="text" name="hour">
<input disabled type="text" name="min">
</div>
</form>
</body>
</html>
Notes: If you change the position of the 'acceptable' selections (currently 'Yes' and 'Maybe'), a little bit of configuration is required here:
Code:
<select name="control1" onchange="enableDisable(this, 1, 2, 'day','month','year','hour','min')">
Their position in the select is represented 0 (which is 'No', in this example) to whatever, make sure the two numbers in red in the above correspond to their actual positions.
Bookmarks