日期:2014-05-19  浏览次数:20696 次

js 提交action
JScript code

        function upload(enterid){
            // document.all('formname').method = "get";
            document.all('formname').action="uploadsinglepic?enterid="+enterid;
            alert(enterid);
            document.all('formname').submit();
        }



我在Struts2 action中

System.out.println(enterid);
System.out.println(ServletActionContext.getRequest().getParameter("enterid"));
都无法获取enterid值?

求帮助!!!

------解决方案--------------------
不行,不能用 form 来提交带参数URL。

你只能先在<form>中定义一个隐藏域:
<input type="hidden" id="enterid" name="enterid">

然后JS中:
document.getElementById("enterid").value = enterid;
------解决方案--------------------
你要是get方式,根本不需要提交form,
只有window.href或replace你的带?好的url就好了。

探讨

document.all('formname').method = "get"; 加上这样的也不行吗?
为什么<a href></a> 这种方式却能Get
是不是js 底层根本没有实现Get方式?

------解决方案--------------------
探讨
不行,不能用 form 来提交带参数URL。

你只能先在<form>中定义一个隐藏域:
<input type="hidden" id="enterid" name="enterid">

然后JS中:
document.getElementById("enterid").value = enterid;

------解决方案--------------------
探讨

引用:
不行,不能用 form 来提交带参数URL。

你只能先在<form>中定义一个隐藏域:
<input type="hidden" id="enterid" name="enterid">

然后JS中:
document.getElementById("enterid").value = enterid;


------解决方案--------------------
document.myform.action="mexposure_approved.action?stateType=pmcApproved&id="+id+"&customerCode="+cusCode;
document.myform.submit();


这样是可以的,action里要有stateType属性的get\set方法