我想在将值输入到作为另一个表单一部分的文本输入字段时提交隐藏表单。
<form name="TDISLabelForm" target="fr1" method='POST' action="/createLabelTDIS.do">
<input type="hidden" name="lab_no" value="<%=lab_no%>">
<input type="hidden" name="accessionNum" value="<%=accessionNum%>">
<input type="hidden" id="label" name="label" value="<%=label%>">
</form>
<iframe style="height:1px;width:1px;border:none:" id="fr1"></iframe>
<form name="ackForm" method="post" action="/UpdateStatus.do">
<button type="button" value="Label">Label</button>
<input type="text" id="label" name="label" value="<%=label%>"/>
<input type="button" onclick="TDISLabelForm.submit()" value="Create">
</form>
当我点击提交TDISLabelForm的“创建”按钮时,我想提交“标签”的值。怎么办呢?
感谢您的帮助。
答案 0 :(得分:2)
这是一个开始,让您继续http://en.wikipedia.org/wiki/XMLHttpRequest
function submitLable(lblval){
var payLoad = document.forms['TDISLabelForm']
.lab_no.value = document.forms['ackForm']
.label.value; // pass the value for visible for to the hidden form
var request = requestObject();
request.open("POST", "/createLabelTDIS.do", false); // post the value to createLabelTDIS.do for further processing as usual.
request.send(payLoad);
}
function requestObject() {
if (window.XMLHttpRequest)
return new XMLHttpRequest();
else if (window.ActiveXObject)
return new ActiveXObject("Msxml2.XMLHTTP");
else
throw new Error("Could not create HTTP request object");
}
<input type="button" onclick="submitLable(this)" value="Create">