how to create this simple little javascript function

K

Ken1

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 :)
 
A

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_'
 
K

Ken1

ASM said:
Ken1 a écrit :

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top