/    Sign up×
Community /Pin to ProfileBookmark

passing values from iframe

here is a link to the page I am working on:
[url]http://www.bruehlus.com/bigarm.html[/url]

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=”” />

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@Khalid_AliSep 15.2003 — 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
Copy linkTweet thisAlerts:
@travisbauthorSep 15.2003 — i did a search and did not find what I was looking for. However, I did not read the sticky.
Copy linkTweet thisAlerts:
@travisbauthorSep 15.2003 — 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');">
Copy linkTweet thisAlerts:
@Khalid_AliSep 15.2003 — yes you can do that as a matter of fact you can pass arrays as well or an array of values..
Copy linkTweet thisAlerts:
@travisbauthorSep 15.2003 — 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];

}
×

Success!

Help @travisb spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...