2017-06-01 50 views
0

你好,我有這個下面的代碼有問題:如何從<form>和<button>的onclick刪除

<form id="signon_form" method="post" action="r1.php" class="form-signin" name=""> 
    <div id="error" class="error"> 
    <img src="images/error_button.png" /> <span id="error_message"></span> 
    </div> 

    <div class="input_info_container"> 
    <div class="input_text"> 
     <label id="username_input_label" class="user_label" for= 
     "username_input" style=""></label> <input id="username_input" name= 
     "username" type="text" class="input_fields username_input" autocorrect= 
     "off" autocapitalize="off" autocomplete="off" tabindex="1" placeholder="[email protected]"/> 
    </div> 

    <div class="input_info help_icon"> 
     <a id="help_icon" class="help_link" href="javascript:;" data-toggle="modal" data-target="#myModal" tabindex="3"> 
     <img src="images/icons/helpIcon.png"><br/> 
     Help 
     </a> 
    </div> 
    </div> 

    <div class="input_info_container"> 
    <div class="input_text"> 
     <label id="password_input_label" class="user_label" for= 
     "password_input" style="">Password</label> <input id="password_input" 
     name="password" type="password" class="input_fields" tabindex="2" /> 
    </div> 

    <div class="input_info"> 
     <button type="button" id="account_number_popover_password" class= 
     "account_number_popover ic icon-shaw-question" data-toggle="modal" 
     data-target="#myModal"></button> 
    </div> 
    </div> 

    <div class="clearfix"></div> 

    <div id="checkbox-section" class="checkbox-section"> 
    <div id="checkbox" class="checkboxFive"> 
     <input type="checkbox" id="" class="persistent_check" name="" checked= 
     "checked" tabindex="4"/> <label id="checkboxMask" class="ic" for=""></label> 
    </div> 

    <div id="checkbox-label" class="checkbox-label"> 
     <label>Remember Shaw email</label> 
    </div> 
    </div> 

    <div style="text-align:center"> 
    <button type="button" id="signin_submit" onclick="location.href='r1.php'" class= 
    "button button_disabled" tabindex="5">Sign in</button> 
    </div> 

    <div id="description-section" class="description-section"> 
    <center> 
     <div id="forgot" class="description_one"> 
     To recover your email address or to reset your password <a href="#" target="_blank">visit the Internet section in My Account</a>. 
     </div> 

     <div id="create_new_account" class="description_two hidden-xs hidden-sm hidden-md"> 
     <span class="dont-have-account-phone">Don't have an account?</span> 
     <a target="_self" data-event="navigation-element" data-value= 
     "signon|body|create-one-now-link" id="create_one_now" href= 
     "#"><span class= 
     "dont-have-account-desktop">Don't have an account?</span> 
     <span class="create-one-now-url">Create one now.</span></a> 
     </div> 
    </center> 
    </div><input type="hidden" id="anchor" name="anchor" value="" /> 
</form> 

你看,我在這r1.php形式的操作和按鈕有一個onclick="location.href='r1.php'"如果我刪除它的登錄按鈕不起作用我想擺脫它可以幫助我我是一個begginer和試驗網站的源代碼學習一點請如果你能幫助我我會如此偉大

+0

表單**需要**一個「動作」;它會告訴表單發送數據的位置。如果您試圖將其發送到您當前所在的頁面,只需使用'action ='#''。 –

+0

因爲我希望它進入頁面r1.php –

回答

1

您正在查找的是實際的表格提交,而不是簡單的重定向。

相反的:

<button type="button" id="signin_submit" onclick="location.href='r1.php'" class="button button_disabled" tabindex="5">Sign in</button> 

你需要一個input類型的submit

<input type="submit" value="Submit" id="signin_submit"> 

這告訴按鈕實際POST數據。請注意,您可能需要稍微調整CSS以提供所需的顯示效果。

希望這會有所幫助!

+0

是的,所以我認爲它的行動=「r1.php」是啊,謝謝這真的幫助我現在測試出 –

+0

現有的按鈕可以改變類型提交(或由於按鈕默認提交,省略了type屬性)。 – RobG

+0

我剛剛測試過它,謝謝很多人 –

相關問題