动态创建form并提交
2017-12-29 本文已影响0人
a9b854aded01
<a href="javascript:formSubmit()" onclick="formSubmit('入库查询')" target="mainFrame" onFocus="this.blur()" id="input_select">入库查询</a>
function formSubmit(elementvalue) {
GetLeftParam();
var QueryForm = document.createElement("form");
document.body.appendChild(QueryForm);
QueryForm.method = 'post';
if(elementvalue == '入库查询') {
QueryForm.action = './input_select';
}
QueryForm.target = 'mainFrame';
var newElement1 = document.createElement("input");
newElement1.setAttribute("value",comname);
newElement1.setAttribute("type","hidden");
newElement1.setAttribute("name","comname");
var newElement2 = document.createElement("input");
newElement2.setAttribute("value",proname);
newElement2.setAttribute("type","hidden");
newElement2.setAttribute("name","proname");
var newElement3 = document.createElement("input");
newElement3.setAttribute("value",goodsname);
newElement3.setAttribute("type","hidden");
newElement3.setAttribute("name","goodsname");
var newElement4 = document.createElement("input");
newElement4.setAttribute("value",specname);
newElement4.setAttribute("type","hidden");
newElement4.setAttribute("name","specname");
var newElement5 = document.createElement("input");
newElement5.setAttribute("value",gradename);
newElement5.setAttribute("type","hidden");
newElement5.setAttribute("name","gradename");
var newElement6 = document.createElement("input");
newElement6.setAttribute("value",manname);
newElement6.setAttribute("type","hidden");
newElement6.setAttribute("name","manname");
var newElement7 = document.createElement("input");
newElement7.setAttribute("value",pakename);
newElement7.setAttribute("type","hidden");
newElement7.setAttribute("name","pakename");
QueryForm.appendChild(newElement1);
QueryForm.appendChild(newElement2);
QueryForm.appendChild(newElement3);
QueryForm.appendChild(newElement4);
QueryForm.appendChild(newElement5);
QueryForm.appendChild(newElement6);
QueryForm.appendChild(newElement7);
QueryForm.submit();
}