473,407 Members | 2,676 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,407 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 6705
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.