473,231 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,231 software developers and data experts.

Retrieve Checkbox Value from Inline Frame

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.

Apr 11 '07 #1
4 6697
On Apr 11, 2:04 pm, "Matt" <matt_marsh...@manning-napier.comwrote:
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.
I think I figured out the Syntax Error. I removed the [] on the for
line. Now I am receiving an "Object required" error on the same line
at char 18. My new line is:

for(var i=0; i < iframeForm.selectedcategories.length; i++){

I assume it is not recognizing either (or both) the inline frame form
and checkbox element).
Apr 11 '07 #2
On Apr 11, 2:26 pm, "Matt" <matt_marsh...@manning-napier.comwrote:
On Apr 11, 2:04 pm, "Matt" <matt_marsh...@manning-napier.comwrote:


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.

I think I figured out the Syntax Error. I removed the [] on the for
line. Now I am receiving an "Object required" error on the same line
at char 18. My new line is:

for(var i=0; i < iframeForm.selectedcategories.length; i++){

I assume it is not recognizing either (or both) the inline frame form
and checkbox element).- Hide quoted text -

- Show quoted text -
Sorry everyone. I figured it out. The issue was the way I was trying
to access the iFrame. Here is my updated script in case you are
interested. Sorry about the premature positng. I had to step away from
it for a while to figure it out.

function showValues(p_frame, p_fieldname){

var iframeForm =
window.frames["categories"].document.SelectCategories;

//create array to hold values of checked 'delete_this' 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)
}

Apr 11 '07 #3
Matt wrote:
>>
>> 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;
should be:
// populate array with checked values:
categories[categories.length] =
iframeForm.selectedcategories[i].value;
You are creating a sparse array when you use the incremental counter.
Mick
Apr 12 '07 #4
for(var i=0; i < iframeForm.selectedcategories[].length; i++){

The first thing to do: remove the [] before the ".length" check, so
the line should read:
for(var i=0; i < iframeForm.selectedcategories.length; i++){

there may be more errors, but that is the most obvious that I see.

Apr 13 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: mike | last post by:
Hi there: I've read an excellent "how to"-article by Microsoft (no. 306227) - partly cited cited at the end of this email). I have implemented the code related to the part "How to Add a...
2
by: Asha | last post by:
greetings, i'm loading a datagrid and my gird has checkbox, i want these checkboxex to be check based on the value from the db? can someone please show me the code for it? thanks
3
by: niftyhawk | last post by:
Hi All, I have a php page say "abc.php" generating the following HTML. I am posting the form action to another php page say "TestCheckbox.php". How do I retrieve in "TestCheckbox.php" which...
6
by: Daz | last post by:
Hi everyone. Firstly, I apologise if this i not what you would call a PHP problem. I get quite confused as to what lives in which realm, so if this shouldn't be posted here, please suggest where...
21
by: Steven T. Hatton | last post by:
I'm trying to improve my formal understanding of C++. One significant part of that effort involves clarifying my understanding of the vocabulary used to describe the language. This is from the...
7
by: sara | last post by:
I have a form where the user is entering information from a phone call. While usually the caller is calling about another person (who will be/is the client), very occasionally, a caller is the...
1
by: whidbey | last post by:
Hello friends, I am whidbey, new to thescripts and dot net as well.I am working over Online Shopping Cart,web application.I design a page (webform5.aspx) where user search books then select the books...
0
by: whidbey | last post by:
Hello friends, I am whidbey, new to thescripts and dot net as well.I am working over Online Shopping Cart,web application.I design a page (webform5.aspx) where user search books then select the books...
1
by: ahilar12 | last post by:
Hi all, I am new to php,my question is that in this following code i am retrieving many rows from the database which is working good.i want to delete a particular row(s) which is checked(checkbox)...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.