in reply to Re^2: OT? Checkbox list with CGI/Javascript
in thread OT? Checkbox list with CGI/Javascript
W3Schools is going to be your best friend, especially if you're just getting started with JS. I haven't tested this but it would most likely look something like this...
var checked_boxes = ""; for(var i=0; i<total_checkboxes; i++) { var cur_box = document.getElementById('userbox_' + i); if(cur_box.checked) { checked_boxes += i + '|||'; } } var all_checkboxes = document.getElementById('all_checkboxes'); all_checkboxes.value = checked_boxes;
now this is assuming all of your userid's are 0,1,2,3,... and the checkbox names are setup with the name/id as 'userbox_0', 'userbox_1', 'userbox_2',... i'm also guessing that you're user id's won't be consecutive like that. you might try populating an array (user_ids for example), then giving that to the javascript via a template variable. once that array is stored in js, you could just use user_ids.length for the total_checkboxes and just use user_ids[i] to reference the user id stored in the array.
you might also want to look at the JSON perl module as well for transferring data to and from javascript applications. this might be confusing at the time if you're just using javascript, but you can find more information at json.org
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: OT? Checkbox list with CGI/Javascript
by rashley (Scribe) on Nov 11, 2005 at 18:30 UTC |