Finding checkboxesl between 2 checkboxes

M

Mark

Hi - I'm using asp.net to draw a grid (dates and people) which is
populated by checkboxes - each check box represents a day and a person
(so for example, I may have 2 weeks showing across the top, with 10
people showing down the side).

Currently, if I click on day 1 person 1, and I want to book their time
for 2 weeks, I have to manually check 14 checkboxes.

Is there a way for me to click on the first checkbox, and then click on
the last one, and have some javascript function populate all the
checkboxes in between?

Thanks for any help,

Mark
 
S

scriptguru

Mark напиÑав:
Hi - I'm using asp.net to draw a grid (dates and people) which is
populated by checkboxes - each check box represents a day and a person
(so for example, I may have 2 weeks showing across the top, with 10
people showing down the side).

Currently, if I click on day 1 person 1, and I want to book their time
for 2 weeks, I have to manually check 14 checkboxes.

Is there a way for me to click on the first checkbox, and then click on
the last one, and have some javascript function populate all the
checkboxes in between?

Thanks for any help,

Mark
var firstCheckBox=... //save reference to checkboxes
var secondCheckBox=... //in this vars
var checkMode=false
var elements=document.forms[0].elements, item
for(var i=0;i<elements.length;i++){
item=elements
if(item.type!='checkbox')continue
if(item==firstCheckBox) { checkMode=true; continue }
if(item==secondCheckBox) break
if(checkMode) item.checked=true
}
 

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,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top