Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jun 2002
    Location
    PA, USA
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Hey javascript gods - iframe and onsubmit issue

    I have a strange issue that someone may be able to help with...

    I have an iframe on a page, and inside the iframe is another page with a form and some text fields and the like. I have a toolbar on the main page with a "SAVE" button on it, and the onclick of the button calls the iframe's form's submit method. I want to place some javascript in the onsubmit of the page with the form, but it ignores the onsubmit event. Everything is setup as you would do it if the page were by itself (ie, in the form tag I have onsubmit="javascript:doVerify();") but "doVerify" never executes. Any ideas Javascript gods?

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    The Planet Earth Code Poet: True
    Posts
    282
    Thanks
    0
    Thanked 1 Time in 1 Post
    Post the code for you form and the doVerify function. Typically the onsubmit call would look like this:

    onsubmit="return doVerify()"


    I can't think of a time when you wouldever have to put:

    javascript:

    into a javascript event handler.

  • #3
    New to the CF scene
    Join Date
    Jun 2002
    Location
    PA, USA
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy

    hmmmm, perhaps I didn't layout the scenario well enough. Let's try this sample...

    Create two HTML pages, call one page1.htm, the other call page2.htm. Put the code for each page accordingly...

    page1.htm:

    <html>
    <head>
    <script>
    function doSaveClick() {
    window.maintframe.document.forms(0).submit();
    }
    </script>
    </head>
    <body>
    <center>
    <input type=button id="save" name="save" value="save" onclick="javascript:doSaveClick();">
    <p>
    <iframe height="300" width="300" id="maintframe" name="maintframe" border="1" frameborder=1 scrolling="auto" src="page2.htm"></iframe>
    </center>
    </body>
    </html>



    page2.htm:

    <html>
    <head>
    <script>
    function doVerify() {
    alert('Doing the verify function!');
    }
    </script>
    </head>
    <body>
    <form id=maint name=maint onsubmit="return doVerify()">
    Enter something: <input type=text id=txtText name=txtText>
    <p>
    Enter something else: <input type=text id=Text2 name=txtText2>
    </form>
    </body>
    </html>


    Then pull up page1.htm, and click the "Save" button. The form in the iframe submits, but the function doVerify is never executed. Is there a way to make that function fire? Or, is there a way to call doVerify from the button click?

    Thanks for your help...

  • #4
    New to the CF scene
    Join Date
    Jun 2002
    Location
    PA, USA
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    OH OH OH OH OH! Great idea... I tried a couple of variations and here is what works:

    In the doSaveClick function:

    function doSaveClick() {
    window.maintframe.document.forms(0).submit();
    window.maintframe.doVerify();
    }

    Works like a champ!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •