Home > database >  Automatically submit after 10 seconds
Automatically submit after 10 seconds

Time:02-23

In javascript, how can I automatically submit after 10 seconds after loading the page? This is the input type:

<input type="submit" name="submit" value="submit">

CodePudding user response:

You don't necessarily need a submit button if you want to submit it automatically, You can use the following code:

setTimeout(() => {
  document.getElementById("FORMID").submit();
}, 10000)

Of course instead of getElementById you can use query selector which selects the form.

CodePudding user response:

Just call the .click method of the button after 10s:

setTimeout(() => {
    document.querySelector("input[type='submit']").click();
}, 10000)
  • Related