Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-08-2003, 09:36 PM   PM User | #1
directweb
New to the CF scene

 
Join Date: Jul 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
directweb is an unknown quantity at this point
multi select checkboxes.

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.

Keith
directweb is offline   Reply With Quote
Old 07-08-2003, 09:41 PM   PM User | #2
Roy Sinclair
Senior Coder

 
Join Date: Jun 2002
Location: Wichita
Posts: 3,880
Thanks: 0
Thanked 0 Times in 0 Posts
Roy Sinclair will become famous soon enough
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?
__________________
Check out the Forum Search. It's the short path to getting great results from this forum.
Roy Sinclair is offline   Reply With Quote
Old 07-08-2003, 10:24 PM   PM User | #3
beetle
Senior Coder

 
Join Date: Aug 2002
Posts: 3,467
Thanks: 0
Thanked 0 Times in 0 Posts
beetle has a little shameless behaviour in the past
What do you think of this?

Let me know if you want to use it.
__________________
My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
“Minds are like parachutes. They don't work unless they are open”
“Maturity is simply knowing when to not be immature”
beetle is offline   Reply With Quote
Old 07-09-2003, 12:29 AM   PM User | #4
directweb
New to the CF scene

 
Join Date: Jul 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
directweb is an unknown quantity at this point
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?
Thanks,
Keith
directweb is offline   Reply With Quote
Old 07-10-2003, 08:37 PM   PM User | #5
directweb
New to the CF scene

 
Join Date: Jul 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
directweb is an unknown quantity at this point
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?
Thanks
directweb is offline   Reply With Quote
Old 07-10-2003, 08:52 PM   PM User | #6
beetle
Senior Coder

 
Join Date: Aug 2002
Posts: 3,467
Thanks: 0
Thanked 0 Times in 0 Posts
beetle has a little shameless behaviour in the past
Oh, sorry. Yes, you have my permission - but you can always use my website to contact me. Better not pursue that career as a detective (j/k )
__________________
My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
“Minds are like parachutes. They don't work unless they are open”
“Maturity is simply knowing when to not be immature”
beetle is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:34 AM.


Advertisement
Log in to turn off these ads.