I am no JavaScript guru so please bear with me and be as detailed as
possible with your response. I thank you in advance.
I have an ASP page that contains form elements. I also have an inline
frame on this page that contains multiple checkboxes with the same
name/id. This is a search form and users need the ability to select
which categories they would like to search for. I have to put the
categories in an inline frame to save real estate on the screen.
What I need to do is submit the main form and also pass the inline
frames checkbox values to the forms processing page. I figured I could
handle the onClick event of the submit button (which is part of the
main form and not within the inline frame) to set a hidden field value
with a string value of all the checked option values from the inline
frame's form on the main form. Then submit the form via JavaScript to
the processing page. I would then be able to access the checkbox
values via the hidden field on my forms processing page.
I am having a problem accessing the inline frame's checkbox values and
populating them into a string. I have cut together a couple scripts I
found online but have had no luck. Here is the script I put together.
function showValues(){
var iframe = document.getElementById("categories");
var iframeDoc = iframe.document;
var iframeForm = iframeDoc.getElementById("SelectCategories");
//create array to hold values of checked 'selectedcategories' items:
var categories = new Array();
for(var i=0; i < iframeForm.selectedcategories[].length; i++){
if(iframeForm.selectedcategories[i].checked){
// populate array with checked values:
categories[i] =
iframeForm.selectedcategories[i].value;
}
}
//change array to a string for sending via form:
var categoryvalues = categories.toString();
document.scannedSearch.iframecategories.value = categoryvalues
//alert(categoryvalues)
}
Description:
categories = the name/id of the inline frame
SelectCategories = the name/id of the form within the inline frame
selectedcategories = the name/id of the checkboxes within the inline
frame
ScannedSearch = the name/id of the main form
iframecategories = the name/id of the hidden form field on the main
form
I receive the following error on the "for" line:
"Syntax Error"
Please let me know if you require any further information and thank
you for your assistance.