Home > Software design >  Redirect to third party webiste on html submit and reset html form
Redirect to third party webiste on html submit and reset html form

Time:08-10

I have one html page in which I am providing one registration form for user like this:

enter image description here

when user clicks on the submit button I want the user to redirect to https://domainname.com with the form variables as query parameters and then reset the form in html file.

But I can only redirect the user to some other site but can not reset the form.

Here is my code:

     <section >
            <div >
                <div  id="joinnow">
                <!-- Form styles-->
                        <h3>Join us today</h3>
                        <form action="https://domainname.com/" target="_blank" id="joinnow-form">
                            <label for="businessname">Your business's name</label>
                            <input type="text" id="businessname" name="businessname" placeholder="Business Name" required>

                            <label for="phonenumber">Contact number</label>
                            <input type="tel" id="phonenumber" name="phonenumber" placeholder="eg. 07700100100" required>

                            <label for="address">Your business's street address</label>
                            <textarea type="text" id="address" name="address" placeholder="eg. 123 Business street" required></textarea>

                            <label for="emailaddress">Email address</label>
                            <input type="email" id="emailaddress" name="emailaddress" placeholder="Eg. [email protected]" required>

                            <a href="https://domainname.com/" target="_blank" >Already registered?</h3><br/><br/>
                            <input type="submit" value="Submit">                            
                        </form>
                <!-- -->
                </div>
            </div>
        </section>

when I click the submit button it redirect the user to https://domainname.com?businessname=&phonenumber=&email=&address= which is ok but I want to reset the form after redirecting.

Any Idea how can I attempt this?

CodePudding user response:

Ok this works:

<form action="" target="_blank" onsubmit=" setTimeout(() => this.reset())">
    <input name="hello">
    <input type="submit">
</form>
  • Related