Jump to content

[SOLVED] using numbers as names for checkboxes


JazzyB

Recommended Posts

Hi everyone,

 

I have a form with checkboxes and I've assigned them names using numbers. The problem is it does not allow the following script to work:

 

<script language=JavaScript>
function checkAll(){
document.form.1.checked = true;
document.form.2.checked = true;
document.form.3.checked = true;
}
function unCheckAll(){
document.form.1.checked = false;
document.form.2.checked = false;
document.form.3.checked = false;
}
</script>

 

Here's the form:

 

<form name="form" id="form">
<table width="309" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#F8F7F6">
              <tr>
                <td width="122"><div align="right">Select All </div></td>
                <td width="20">
			<input type="checkbox" name="checkbox" value="checkbox" onClick="if (this.checked){checkAll()} else if (!this.checked){unCheckAll()}" /></td>
                <td width="112"><div align="right">box1</div></td>
                <td width="25">
<input type=checkbox name=1  value=yes />				</td></tr>
              <tr>
                <td><div align="right">box2 </div></td>
                <td>
<input type=checkbox name=2  value=yes />             </td>
                <td><div align="right">box3</div></td>
                <td><input type=checkbox name=3 value=yes /></td>
              </tr>
              <tr>
                <td> </td>
                <td> </td>
                <td><input type="submit" name="Submit" value="Submit" /></td>
                <td> </td>
              </tr>
  </table>
</form>

 

The script works when the names of the checkbox contain letters. Is there any way that I can make it work with only numbers?

 

Please help.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.