How to add a condition to setTimeout ( ) for submit button? newbie

I have a form, what i m looking for is when user clicks submit button then its redirected to a specific page,

<input type="submit" value="Submit" name="submitbutton1" id="btn-submit-btn">

How do I modify this code to my requirement? right now it's just redirecting upon visiting, Please someone help me add only submit button condition.

<script> setTimeout(function() { window.location = "index.php"; }, 2000); </script>

Hi and Welcome to the Forum!

I do not have much experience with forms but it appears straightforward enough to answer this particular question...

You do not need the "timeout" and the clicking the "Submit" button simply takes the viewer to the desired page. In the example below clicking on the "Submit" btn goes to Apple's "Home" page:

<form action="">
  <label for="fname">First name:</label><br>
  <input type="text" id="fname" name="fname" value="John"><br>
  <label for="lname">Last name:</label><br>
  <input type="text" id="lname" name="lname" value="Doe"><br><br>
  <input type="submit" value="Submit">
1 Like