parent/iframe set iframe source and submit form

Discussion in 'Javascript' started by, Mar 9, 2006.

  1. Guest

    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

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

    At one point i tried doing both in one function on the main page:
    function startupload() {
    var iframe = document.getElementById("progframe");
    iframe.src = "";

    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() {
    <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, 2006
    1. Advertisements

  2. mscode3 Guest

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

    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.
    mscode3, Mar 9, 2006
    1. Advertisements

  3. Guest

    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() {
    frames['progframe'].location.href = "";

    The form button triggers an onClick even calling the script.

    hope that helps anyone else that may have had issues.
    , Mar 9, 2006
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page