...

View Full Version : Looking for a script..



Taylor_1978
10-21-2005, 11:09 AM
Hiya,

I'm wanting a script that will disable 3 drop down boxes unless a check box is ticked.

Any help appreciated!

Thanks in advance! :thumbsup:

rm-f
10-21-2005, 03:20 PM
<html>
<head>
<script>
function enableDisableGroup(flag) {
var grp = document.getElementsByName('grp1');
for(var i=0; i<=grp.length; i++) {
grp[i].disabled = !flag;
}
}

function cbF() {
enableDisableGroup(document.getElementById('grpCb').checked);
}

function loadFnc() {
enableDisableGroup(document.getElementById('grpCb').checked);
}
</script>
</head>
<body onload="loadFnc();">
Dropdown enabled: <input id="grpCb" type="checkbox" onclick="cbF();">
<br>
<select name="grp1">
<option>1-1</option>
<option>1-2</option>
<option>1-3</option>
</select>
<select name="grp1">
<option>2-1</option>
<option>2-2</option>
<option>2-3</option>
</select>
<select name="grp1">
<option>3-1</option>
<option>3-2</option>
<option>3-3</option>
</select>
</body>
</html>

Pyth007
10-21-2005, 05:06 PM
Note that rm-f's code may cause some problems if you plan to submit the form since all of the select-lists are named the same... You may also want to give each separate id's if you need to make a distinction between them in your code.

vwphillips
10-21-2005, 07:24 PM
see

http://www.vicsjavascripts.org.uk/FormCompendium/FormCompendium.htm#f40

there are other disable scripts within FormCompendium if that one does not fit



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum