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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.