Hi
I'm using a small script that enables or disables input fields based on a selection from a drop down list. By default all fields are DISABLED.
This all works fine, but when the page loads I'd like to call this code and have it automatically enable the fields, but only if the referrer is a specific page.
I can take care of the referrer part, but how would I call this code and have it enable the fields ?? The 3rd option on the drop down list enables all the fields.
Is it possible to 'onpage load' to pass those values to the script ?
Thanks 🙂
The script is :
<script language="JavaScript" type="text/javascript">
function zxcEnableDisable(zxcobj){
zxcval=zxcobj.options[zxcobj.selectedIndex].id
if (zxcval.length<1){ return }
zxcenable=zxcval.split('^')[1].split(',');
for (zxc0=1;zxc0<zxcenable.length;zxc0++){
zxcobj=document.getElementById(zxcenable[zxc0]);
zxcobj.removeAttribute('disabled')
}
zxcdisable=zxcval.split('^')[0].split(',');
for (zxc1=1;zxc1<zxcdisable.length;zxc1++){
zxcobj=document.getElementById(zxcdisable[zxc1]);
zxcobj.setAttribute('disabled','disabled')
}
}
</script>
The form input field is like this :
<tr>
<th>Update</th>
<td><select name="mmsms" id="mmsms" onchange="zxcEnableDisable(this);">
<option id="D,field1,field2,field3^E" value="0">ABC</option>
<option id="D,field1,field2,field3^E" value="1">DEF</option>
<option id="D^E,field1,field2,field3" value="2">GHI</option>
</select></td>
</tr>
The first option on the drop down ensures all the fields are disabled as does the second.
The third option enables all the fields.
Thanks 🙂