Click to See Complete Forum and Search --> : passing values from iframe


travisb
09-15-2003, 09:50 AM
here is a link to the page I am working on:
http://www.bruehlus.com/bigarm.html

I am tring to pass a value from an iframe to a form on the parent page but cannot seem to get it to work.


here is the code in the iframe:
<div onClick="parent.passpro(Big Arm 1 seater);">

on the parent I have this in the head:
<script language="JavaScript">
function passpro(str) {
order_form.pro.value = 'str';
}
</script>

and a form in the parent:
<form name="order_form">
Product:<br />
<input type="text" size="15" name="pro" value="" />

Khalid Ali
09-15-2003, 10:00 AM
you should have read the first sticky message on these forums,
http://forums.webdeveloper.com/showthread.php?s=&threadid=16096

this thread has been answered so many times that its funny.

Please search the forums first to see if your question has been answered

travisb
09-15-2003, 10:09 AM
i did a search and did not find what I was looking for. However, I did not read the sticky.

travisb
09-15-2003, 10:27 AM
I did figure out the soluition, but I also have a new question.
here is the code in the iframe:

<div onClick="parent.passpro('Big Arm 1 seater');"> //added single quotes

on the parent I have this in the head:

<script language="JavaScript">
function passpro(str) {
document.order_form.pro.value = 'str';
}// added document
</script>

My new question is can I pass more than one value when the user clicks the link. For example I add the model number:

<div onClick="parent.passpro('Big Arm 1 seater, 34051');">

Khalid Ali
09-15-2003, 10:37 AM
yes you can do that as a matter of fact you can pass arrays as well or an array of values..

travisb
09-15-2003, 10:57 AM
I am having trouble trying to get multiple values in an array like this:

in the iframe:
<div onClick="parent.passpro('prod_array[]:[Big Arm 1 seater][35401]');">

and putting them in the form on the parent with:
function passpro(array[]) {
document.order_form.pro.value = array[0];
document.order_form.mod.value = array[1];
}