Javascript Array
I have a Javascript function that loops through the checkboxes of a form and retrieves the "value" for a checkbox if it is checked.
I want to store these "values" in an array and pass the array to a Java class. If I test this and check 3 boxes, the "values" for those three boxes can
be displayed individually with the javascript alert function when you loop through the array in the script, but all three "values"
are stored in the first index/element of the array when it is read by the Java program.
1. Javascript function in a j2ee application:
function checkNumofAlertIDs(formName) {
var checkBoxes = document.alert_master_listing_form.alertID;
var num = 0;
var getAlertIDs = new Array();
for (i=0; i<checkBoxes.length; i++) {
if (checkBoxes.type="checkbox") {
if (checkBoxes.checked) {
getAlertIDs[num] = formName.alertID.value;
num = num + 1;
}
}
}
return getAlertIDs;
}
2. The name of the checkbox element on the form is "alertID" and that is the name of the variable being passed to the Java class. The form itself is not being submitted.
3. The output displays from Java class:
AlertMgr :: moveMyAlerts() .....alertID = [Ljava.lang.String;@75541c
AlertMgr :: moveMyAlerts() .....alertID[#] = 2007041926005947048973,2007041926235971747056,2007041926249566747431
4. What I need to pass to the java class is an array containing three elements:
alertID[0] = 2007041926005947048973
alertID[1} = 2007041926235971747056
alertID[2] = 2007041926249566747431
Your expertise and help are greatly appreciated!>

