View Full Version : multi select checkboxes.

07-08-2003, 10:36 PM
Hi, i'm looking to make a JS that will let users select multiple checkboxes. I want to be able to hold down shift, click a checkbox, hold shift again, click another checkbox, and then, all the checkboxes between the two that i clicked should be checked. Can someone help me out with the script for that? I would really appreciate it.

I'm sure this shouldn't be too hard to whip up in JS.
1. Make sure each input field is <input type="checkbox" order="1" ...>,
where order is sequential from 1 down the page
2. Add JS so on each 'onclick', it keeps track of 'order' item of the last
clicked checkbox
3. If the click has shift held down, make sure you check/uncheck everything
between the last clicked on checkbox (as saved in step 2) and the current
checkbox. Since they're sequential, easy to do, just count up or down
towards the current one.


Roy Sinclair
07-08-2003, 10:41 PM
Question: Do you want it to check everything if the current checkbox is unchecked and uncheck everything if the current box is checked or simply check everything that's currently unchecked and uncheck everything that's currently checked?

07-08-2003, 11:24 PM
What do you think of this? (http://www.peterbailey.net/dhtml/DragToCheck.htm)

Let me know if you want to use it.

07-09-2003, 01:29 AM
hey beetle,
that is great. wonderful.. didnt even think of something like that..
Would you consider letting me use it?
I would also like something like what my boss suggested though..
Here's the scenario i am thinking of..
i want to be able to select groups of checkboxes.
If i hold shift, and click a box.
Then, i go down the list, and hold shift, and click another box,
all the boxes between the two that i clicked should also be checked.

The reverse should also be possible.
(hold shift, and select 2 boxes, and everything between gets unchecked)

Anyone have any ideas?

07-10-2003, 09:37 PM
hi beetle, is there any other way that i can contact you? via email perhaps, so you can give me permisson to use your script?

07-10-2003, 09:52 PM
Oh, sorry. Yes, you have my permission - but you can always use my website (http://www.peterbailey.net/) to contact me. Better not pursue that career as a detective (j/k ;) )