• 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页面

  • 相关阅读:
    【扫盲】模块 库 框架 包
    AJax和JQ的结合使用
    AJax的三种响应
    使用session存储数据
    Requset作用域
    Cookie实现记住密码代码
    Cookie技术
    请求转发和重定向
    重定向的两次请求分别是????
    servlet
  • 原文地址:https://www.cnblogs.com/winstonet/p/6916278.html
Copyright © 2020-2023  润新知