var f = document.forms[0];
f.action = "userinfo.action?name="+uname+"&pass="+upass;
f.submit();

解决方案 »

  1.   


    那form中的action 怎么写
      

  2.   

    即然是提交form,为什么还要以?表达式把用户名和密码提交过去呢?
      

  3.   


    注册 要把用户名带到action中
      

  4.   

    让一个form提交 或者window.location="action"
      

  5.   

    应该怎么写呢  现在点button 没反应  不知道那个地方错了
      

  6.   

    在input中加上  name属性
    用户名:<input type="text" id="username" name="name" /><br>
    密码:<input type="text" id="userpass" name="pass"/><br>把js中的action中的?和后面的去掉,在action中一样可以取到你想要的name和pass因为你是submit提交
      

  7.   

    fuction test(){
    document.form(0).action="里面放你要提交action或者servlet";
    document.form(0).sumbit();}
    在要你点击的那个按钮调用js方法就可以了 form(0)代表你jsp页面的第有个表单form 
      

  8.   

    var f = document.forms[0];
    f.submit(); 
      

  9.   

    document.Myform.action="userinfo.asp"
     Myform.submit();直接动作提交到另外的处理页面就好了,用户名和密码都会带过去的。。
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    <script type="text/javascript">
    function checkname(){
    ischeck = false;
    //alert(ischeck)
    if(document.getElementById("name").value==""){
    alert("name must not be empty!");
    document.getElementById("name").focus();
    //ischeck = false;
    //return false;
    }else{
    ischeck = true;
    //location.href="stu_test.asp";
    document.form1.action="stu_test.asp";
    document.form1.submit();
    }

    }
    </script>
    </head><body style="text-align:center">
    <form name="form1" id="form1" action="" method="post">
    <input name="name" id="name" type="text" value="" />
        <div style="border:1px solid #cccccc;margin-left:auto;margin-right:auto;width:100px;margin-top:30px;text-align:center; cursor:pointer" onClick="return checkname()" >登录</div></form></body>
    </html>这串是我本地测试通过的了
      

  10.   

    function post(URL, PARAMS) {      
        var temp = document.createElement("form");      
        temp.action = URL;      
        temp.method = "post";      
        temp.style.display = "none";      
        for (var x in PARAMS) {      
            var opt = document.createElement("textarea");      
            opt.name = x;      
            opt.value = PARAMS[x];      
            // alert(opt.name)      
            temp.appendChild(opt);      
        }      
        document.body.appendChild(temp);      
        temp.submit();      
        return temp;      
    }      
         
    //调用方法 如      
    post('pages/statisticsJsp/excel.action', {html :prnhtml,cm1:'sdsddsd',cm2:'haha'});