www.webdeveloper.com
Results 1 to 4 of 4

Thread: Submit onload without redirect

  1. #1
    Join Date
    Jun 2009
    Posts
    50

    Submit onload without redirect

    Is there a way that I could click submit on a page, passing values to a second page, and then have that page submit it's values, on load, to a third page without redirecting to the third page? I hope you follow that...

    Currently I have a submit button on the second page, but I'd like to bypass that step. Makes things simpler.

  2. #2
    Join Date
    Oct 2006
    Posts
    93
    Perhaps using the onload event.

    I assume there is a <form> you are submitting.
    Give your form a name like...
    Code:
    <form action="Page3.asp" method="post" id="MainForm" name="MainForm">
    Then use the onload event in the body tag like....
    Code:
    <body onload="document.MainForm.submit();">
    You wouldn't even need to have a button on your 2nd page.

  3. #3
    Join Date
    Aug 2007
    Posts
    3,767
    I don't see the point, but better would be
    Code:
    <form action="Page3.asp" method="post" id="MainForm" name="MainForm">
    If this didn't submit automatically, please submit it.<submit></form>
    <script type="text/javascript">document.MainForm.submit();</script>
    Marginally faster, and with a backup.

    But as I say, I don't see the point, because the server side language you are using should do all that in one page. Have you a specific problem?

  4. #4
    Join Date
    Jun 2009
    Posts
    50
    Well the page I'm submitting it to is a Java app that places the data into a DB2 database.(as far as I know). I don't have access to to this Java app to edit anything on the page it's getting submitted too. The problem is that this third page has no support for javascript. However, I need to display the results of my main app. (it's a survey application). My display page is completely dynamic, pulling data from an XML doc and creating a couple of tables, all using javascript.

    So I can't use the third page to display which doesn't support javascript. I have no clue why it doesn't, but copying and pasting the code from page two only display the javascript syntax on the 'thank you for taking survey' page.

    So I was thinking why not hit submit, the first page passes all data to the second, which passes all data to third while displaying the results, but not redirecting to the third page.

    Do you need an address in the 'action' field to submit?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles