View Full Version : Post to an iFrame

07-31-2010, 11:40 PM

How can I extend this so that it posts the data from these 2 fields to an iframe,
and what code do I need in the iframe to capture the data and present it in 2 fields?

On the sending page, I have

<script type="text/javascript">
function passValue() {
var ddl = document.getElementById("ddlName");
var index = ddl.selectedIndex;
document.getElementById("txtValue").value = ddl.value;
document.getElementById("txtName").value = ddl.options[index].text;

<iframe ID="first_iframe" src="http://xxx.net/iPage.html" width="600" height="400">

sample code appreciated. Thanks

08-01-2010, 12:15 AM
<form target="first_iframe" action=""http://xxx.net/iPage.html">
//your inputs here

<iframe ID="first_iframe" width="600" height="400">

08-01-2010, 02:27 AM
Thanks for your effort;
The form is not being submitted by a submit button. The function is the result of a SELECT as part of a Listbox.

What I'm looking for is the correct code to extend the function to include the post to the iframe.

08-01-2010, 03:30 AM
Got it to work using

document.getElementById("iframe").contentDocument.getElementById("txtValue").value = ddl.value;

Problem with Firefox. Somehow, it wouldn't work there.

Thanks anyway..

08-01-2010, 02:20 PM
well to submit a form with JavaScript you have to use:


08-01-2010, 11:34 PM
semiSkim :

You are correct. Its my vocabulary.
I'm just selecting a value and passing it to input boxes and the iframe. I'm not actually submitting the values somewhere else.

You were a great help. Thanks