470,636 Members | 1,612 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,636 developers. It's quick & easy.

how to create this simple little javascript function

Hello,
I have a list of checkboxes on a page... There is a certain list that
is numbered from 1 to n which i want to be able to "check all/none"
its easy to create this for all the checkboxes on the page but how
would i go about creating one that will only check those that are
numbered from 1 to n altho i dont know up to which number they go...
sometimes it can be from 1 to 5 or sometimes 1 to 99...
thanks :)

Oct 29 '06 #1
2 1017
ASM
Ken1 a écrit :
Hello,
I have a list of checkboxes on a page... There is a certain list that
is numbered from 1 to n which i want to be able to "check all/none"
its easy to create this for all the checkboxes on the page but how
would i go about creating one that will only check those that are
numbered from 1 to n altho i dont know up to which number they go...
sometimes it can be from 1 to 5 or sometimes 1 to 99...
thanks :)
anyway your checkboxes are named and names can't begin with a number
so their names could be this way :

<input type=checkbox name="ch_1" ...
<input type=checkbox name="ch_2" ...
...
<input type=checkbox name="ch_99" ...

you'll make a loop on elements of your form and will modify only
checkboxes of which names begin with 'ch_'
Oct 29 '06 #2

ASM wrote:
Ken1 a écrit :
Hello,
I have a list of checkboxes on a page... There is a certain list that
is numbered from 1 to n which i want to be able to "check all/none"
its easy to create this for all the checkboxes on the page but how
would i go about creating one that will only check those that are
numbered from 1 to n altho i dont know up to which number they go...
sometimes it can be from 1 to 5 or sometimes 1 to 99...
thanks :)

anyway your checkboxes are named and names can't begin with a number
so their names could be this way :

<input type=checkbox name="ch_1" ...
<input type=checkbox name="ch_2" ...
...
<input type=checkbox name="ch_99" ...

you'll make a loop on elements of your form and will modify only
checkboxes of which names begin with 'ch_'
alright thanks

Oct 30 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Mark | last post: by
24 posts views Thread by firstcustomer | last post: by
1 post views Thread by Korara | last post: by
???
reply views Thread by Stoney L | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.