jamescover
07-07-2004, 09:08 PM
Hi:
I have 20 checkboxes (just 3 showing in the sample below), and I want to determine which out of the 20 have actually been checked, then store their name values in an array. At least, I think that is the way to go, but I'm open to suggestions.
function checkForm(){
var mCB = new Array(myForm.img1Chkbx,myForm.img2Chkbx,myForm.img3Chkbx)
for (i=0;i<mCB.length;i++){
if(mCB[i].checked){
n = mCB[i].name;
var mCBc = new Array(n);
alert (mCBc);
}
}
}
I thought that I might loop through the boxes array (mCB) then use "checked" to get the output I needed, but as you can see (above), I didn't get very far...
I want to store all name values for all checked boxes. Then I want to be able to access that information, so that I can produce output based on each box checked...how might I do that???
BTW, there are about 150 form elements total (The above function is just one out of a larger script, so the elements array is out). The basic script is itself a "script generator" for an image preloading script, made to accomodate up to 20 images. The script will take the value of each image (only the boxes that are checked), and write the anchor tags and popup script for them.
Here is a link to the popup script:
http://www.ekigroup.com/javascript/working.html
And below is a link to the script generator (thread topic), that will produce the script and links for the popup preloader script:
http://www.ekigroup.com/javascript/workGenForm.html
I'm not looking for someone to write the script for me, just a push in the right direction, i.e., how to populate a new array with checkbox name values, then how to extract that information for future application.
One final note: The script has to be Javascript 1.3 compliant. I didn't have much success with the push() method.
Any and all help appreciated. Thanks.
-james
I have 20 checkboxes (just 3 showing in the sample below), and I want to determine which out of the 20 have actually been checked, then store their name values in an array. At least, I think that is the way to go, but I'm open to suggestions.
function checkForm(){
var mCB = new Array(myForm.img1Chkbx,myForm.img2Chkbx,myForm.img3Chkbx)
for (i=0;i<mCB.length;i++){
if(mCB[i].checked){
n = mCB[i].name;
var mCBc = new Array(n);
alert (mCBc);
}
}
}
I thought that I might loop through the boxes array (mCB) then use "checked" to get the output I needed, but as you can see (above), I didn't get very far...
I want to store all name values for all checked boxes. Then I want to be able to access that information, so that I can produce output based on each box checked...how might I do that???
BTW, there are about 150 form elements total (The above function is just one out of a larger script, so the elements array is out). The basic script is itself a "script generator" for an image preloading script, made to accomodate up to 20 images. The script will take the value of each image (only the boxes that are checked), and write the anchor tags and popup script for them.
Here is a link to the popup script:
http://www.ekigroup.com/javascript/working.html
And below is a link to the script generator (thread topic), that will produce the script and links for the popup preloader script:
http://www.ekigroup.com/javascript/workGenForm.html
I'm not looking for someone to write the script for me, just a push in the right direction, i.e., how to populate a new array with checkbox name values, then how to extract that information for future application.
One final note: The script has to be Javascript 1.3 compliant. I didn't have much success with the push() method.
Any and all help appreciated. Thanks.
-james