By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,763 Members | 1,609 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,763 IT Pros & Developers. It's quick & easy.

parent/iframe set iframe source and submit form

P: n/a
Ok, I've been at this two days now and have scoured the group for help
to no avail.

I have a main web page that contains a form and an iframe. I need to
submit the form and set the iframe source file in one action and have
it work with both IE and other browsers. So far, i have not had any
luck.

Form name "fmUpload", frame name, "progframe".

At one point i tried doing both in one function on the main page:
function startupload() {
document.fmUpload.action="http://newurl.com/form.html";
var iframe = document.getElementById("progframe");
iframe.src = "http://newurl.com/iframe.html";
}

Did not work in both IE and FF.

Then i tried doing the set iframe src on the form button click, then
the new iframe page submit the parent form using a body onLoad. That
did not work in IE with:

function subForm() {
parent.document.forms.fmUpload.submit();
}
</script>
<body onLoad=subForm()>

This really hurts. If anyone can help me with a simple explanation, i
would appreciate it. Code would be much appreciated!

Mar 9 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
The thing that catches my eye here is where you say that you have "Form
name "fmUpload", frame name, "progframe"". If the <iframe> is written
as
<iframe name="progframe">...</iframe>
then in the JavaScript, the line,
var iframe = document.getElementById("progframe");
will not work. The proper HTML would have to be:
<iframe id="progframe">...</iframe>

document.forms["fmUpload"].action="http://newurl.com/form.html";
should work too and may be a bit more clear.

Other than that, the js function looks OK and should work in both IE
and FF

If this doesn't help, let me know.

Mar 9 '06 #2

P: n/a
Thanks for the reply. I managed to get it running in both IE and FF.
The order the code was executed in happend to make a difference for
some reason. Doing the frame location before th form submit changed teh
frame location without the action

here is my final code:
<SCRIPT Language="JavaScript">
function startupload() {
{
{
document.fmUpload.action="http://xxx.com/xxx>";
document.fmUpload.submit();
}
frames['progframe'].location.href = "http://yyy.com/yyy";
}
}
</script>
The form button triggers an onClick even calling the script.

hope that helps anyone else that may have had issues.

Mar 9 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.