Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7042245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:08:42+00:00 2026-05-28T02:08:42+00:00

My website needs to have a form that automatically submits, sending the user (with

  • 0

My website needs to have a form that automatically submits, sending the user (with POST data) to an external website. Previously, I was using HTML like this:

<html>
  <head></head>  
  <body onload="document.forms[0].submit()">
    <form name='form1' method='post' action='externalwebsite.com'>
      <input type='hidden' name='cartId' value='1337'>
      <input type='hidden' name='currency' value='USD'>
      <input type='hidden' name='amount' value='9'>
    </form>
  </body>
</html>

However, this resulted in a long delay between the page loading and the form being submitted, as the onload event fires very late in the page lifecycle.

Javascript libraries have the domready event, to allow code to before the onload event fires, but still at a point where it is safe to manipulate the DOM tree. For instance, with the Mootools library, I could do this:

window.addEvent('domready', function () {
    document.forms[0].submit();
});

However, I don’t want to include a bulky javascript library for such a simple page. As such, I have the following HTML:

<html>
  <head></head>  
  <body>
    <form name='form1' method='post' action='externalwebsite.com'>
      <input type='hidden' name='cartId' value='1337'>
      <input type='hidden' name='currency' value='USD'>
      <input type='hidden' name='amount' value='9'>
    </form>
    <script type='text/javascript'>document.forms[0].submit()</script>
  </body>
</html>

Will this always work, across all browsers? Or should I use a different method?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:08:43+00:00Added an answer on May 28, 2026 at 2:08 am

    put the script before closing body tag

    <html>
      <head></head>  
      <body>
        <form name='form1' method='post' action='externalwebsite.com'>
          <input type='hidden' name='cartId' value='1337'>
          <input type='hidden' name='currency' value='USD'>
          <input type='hidden' name='amount' value='9'>
        </form>
      <script type='text/javascript'>document.forms[0].submit()</script>
      </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a registration form for a website that needs to check if an
I have a form on a website that needs validating before entering the form
I have code in an ASP.NET form that needs to, depending on user entry
I have a WordPress website that needs to have its articles in multiple languages.
I have an application that needs to check a website feed every second. Sometimes
I have a website that relies on dependency injection, using Castle Windsor. I need
I have a website with a Java Applet and that applet needs to connect
I have a website that deals with a huge amount of data in the
I have a website that is using SMF forum (simplemachines.org). I have been using
I have a WebBrowser in my form that accesses a website that is too

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.