parent/iframe set iframe source and submit form

S

superfreaker

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!
 
M

mscode3

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.
 
S

superfreaker

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top