JavaScript動態修改html組件form的action屬性


用javaScript動態修改html組件form的action屬性,可以在提交時再決定處理表單的頁面。

<%--JavaScript部分--%>
<script language="javascript">
    <%--略掉其余代碼--%>
    if(usertypevalue=="company"){
         document.form.action="./company.jsp"
         document.form.submit();
    }
     else if(usertypevalue=="user"){
        document.form.action="./user.jsp"
         document.form.submit();
     }
     else if(usertypevalue=="tourism"){
         document.form.action="./tourism.jsp"
         document.form.submit();
     }
    <%--略掉其余代碼--%>
</script>

<%--html部分代碼--%>
<form name="form" id="form" action="" method="post">    
     <%--略掉其余代碼--%>    
     <input type="radio" name="usertype" id="usertype" value="tourism">旅游局
    <input type="radio" name="usertype" id="usertype" value="company">公司
    <input type="radio" name="usertype" id="usertype" value="user" checked="checked">游客        
    <br>
    <input type="button" value="確認" onclick="validate();">
    <input type="reset" value="重置">
        <%--略掉其余代碼--%>
</form>

這樣就可以在檢查用戶信息后,把參數用post方法傳給另一不確定jsp頁面


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM