简体   繁体   中英

How to redirect after submit

I would really appreciate some help with a code I have. I want to redirect the submitter to any page of my choice after the form data has been submitted.

If you plug the code into the following link " http://www.w3schools.com/html/tryit.asp?filename=tryhtml_default " and follow the prompts, you'll see when it gets to the "Appointment Summary" page there is text at the top instructing the user to "click here to pay deposit". The issue I am having is people are not clicking the text to be redirected. I would like for after user submits form aka schedules appointment the appointment summary page is visible for a few seconds then the user is automatically redirected to the url page of my choice. I also don't want the text "CLICK+HERE+TO+PAY+YOUR+DEPOSIT" to be visible at all on the account summary, just redirect after form has been submitted.

Here is the code:

    <iframe id="schedulista-widget-00" 
    src="https://www.schedulista.com/schedule/neecostylez?
    mode=widget&rt_url=http://www.neecostylez.com/product-page/b58af64e-f174-6c25-a524-
    6388b7ddd6b7&rt_text=CLICK+HERE+TO+PAY+YOUR+DEPOSIT" ="true" 
    frameborder="0" scrolling="no" width="100%" height="900px">
    </iframe><script id="schedulista-widget-script-00" type="text/javascript" 
    src="https://www.schedulista.com/schedule/neecostylez/widget.js"></script>

This is where I'd like for it to be redirected too AFTER user has (submitted form) aka Scheduled their appointment. http://www.neecostylez.com/product-page/b58af64e-f174-6c25-a524-6388b7ddd6b7

This is very simple window.location = "http://www.yoururl.com";

Here is the w3school link: http://www.w3schools.com/js/js_window_location.asp

If you need to redirect using PHP, this will be helpful: How to make a redirect in PHP?

Just add to this answer if anyone else is looking for the same this WOULD NOT WORK FOR SCHEDULISTA WIDGET . That is because of cross origin policy and schedulista doesnt give you access to their end code.

Below solution would only work if you have access to iframe code.

we add a event trigger like onClick to the submit button in the iframe and trigger a funtion in parent window.Calling funtion from iframe submit button using the following:

parent.redirect_function();

At this point in the parent window we can add a set timeout for how everlong you would like to wait before the redirection(reloading the url for the iframe.)

function redirect_function(){
setTimeout(function(){ 
document.getElementById('myframe').src = 'http://www.test.com'; 
}, 3000);
}



/* IFrame  */

<form method="post"  id="myform" name="myform" action="/"  >
<input type="text" name="input1" value="2073809442" />
<input type="text" name="input2" value="1" />
<input type="submit" name="submit" value="submit" onClick="return parent.redirect_function();" />
 </form>

/* Script in parent window */

    function redirect_function(){
    setTimeout(function(){ 
    document.getElementById('myframe').src = 'http://www.exsamp.com'; 
    }, 3000);
    }


/* Html for iframe in parent window */

<iframe frameborder="0" scrolling="no" width="530" height="298"
  src="iframe.html" name="myframe" id="myframe">
  <p>iframes are not supported by your browser.</p>
</iframe><br />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM