PDA

View Full Version : Enable Disable List Array upon Checkbox click



clewis4343
31 May 2011, 03:16 PM
I am needing to disable form elements. I cannot for the life of me figure out how to disable a menu that is an array. HELP!!

Here is my code.

<SCRIPT LANGUAGE="JavaScript"><!--
function codename() {

if(document.formname.checkboxname.chec…
{
document.formname.test.disabled=false;
}

else
{
document.formname.test.disabled=true;
}
}

//-->
</SCRIPT>

<form action="" method="" name="formname">


<select name="test[]" disabled>
<option>12345678</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
</select>

<input type="checkbox" onclick="codename()" name="checkboxname" value="ON">



</form>

There becomes a syntax error if I add the " [ ] " to the element in the script.