最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How do I make submit button redirect to another page? - Stack Overflow

programmeradmin3浏览0评论

I'm trying to figure out how to make the "Submit" button redirect to another page. For example once the user pletes the registration form then clicks "Submit" the user is then redirected to the login page.

 <div class="form-group">
            <div class="checkbox col-sm-10 col-sm-offset-2">
                <button type="submit" name="submitf" value="register" class="btn_dark_grey">{translate text='register'}</button>
            </div>      
        </div>

Thanks in advance.

I'm trying to figure out how to make the "Submit" button redirect to another page. For example once the user pletes the registration form then clicks "Submit" the user is then redirected to the login page.

 <div class="form-group">
            <div class="checkbox col-sm-10 col-sm-offset-2">
                <button type="submit" name="submitf" value="register" class="btn_dark_grey">{translate text='register'}</button>
            </div>      
        </div>

Thanks in advance.

Share Improve this question asked Dec 5, 2016 at 12:53 okarimokarim 411 gold badge1 silver badge6 bronze badges 4
  • 1 You are looking for the action attribute of the form tag : w3schools./tags/att_form_action.asp – Tmb Commented Dec 5, 2016 at 12:55
  • 2 that redirection can be done from the backend. so your form submits on url for ex. /submit at that url just redirect to the url where you want. – Sagar Rabadiya Commented Dec 5, 2016 at 12:55
  • You have to do this on server-side , if still you want to done at client side then use window.location.href = "http://stackoverflow."; – Satinder singh Commented Dec 5, 2016 at 12:57
  • Possible duplicate of How to make a redirect in PHP? – Funk Forty Niner Commented Dec 5, 2016 at 13:03
Add a ment  | 

4 Answers 4

Reset to default 1

This can be done by using the html "form" element. So you can simply do it by

<form action="login.php" method="post">
 <div class="form-group">
        <div class="checkbox col-sm-10 col-sm-offset-2">
            <button type="submit" name="submitf" value="register" class="btn_dark_grey">{translate text='register'}</button>
        </div>      
    </div>
</form>

Try using your code.

Which will be similar to this:

<form action="action_page.php">
  First name:<br>
  <input type="text" name="firstname" value="Mickey"><br>
  Last name:<br>
  <input type="text" name="lastname" value="Mouse"><br><br>
  <input type="submit" value="Submit">
</form> 

use form to make it simple and clear

<form action="login.aspx" method="get">
    <input type="submit" value="Submit">
</form>

Try to add onclick event, onclick="window.location.href = 'http://stackoverflow./'; this will open the url in the same window.

window.open(url) will open the link in a new window https://jsfiddle/sjo02rqe/

 <div class="form-group">
   <div class="checkbox col-sm-10 col-sm-offset-2">
     <button type="submit" name="submitf" value="register" class="btn_dark_grey" onclick="window.open('http://www.google.');">{translate text='register'}</button>
   </div>
 </div>

Hope i helped

发布评论

评论列表(0)

  1. 暂无评论