本文介绍了提交隐藏表单HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在将值输入到另一个表单的文本输入字段中时提交隐藏表单。
< form name =TDISLabelFormtarget =fr1method ='POST'action =/ createLabelTDIS.do >
< input type =hiddenname =lab_novalue =<%= lab_no%>>
< input type =hiddenname =accessionNumvalue =<%= accessionNum%>>
< input type =hiddenid =labelname =labelvalue =<%= label%>>
< / form>
< iframe style =height:1px; width:1px; border:none:id =fr1>< / iframe>
< form name =ackFormmethod =postaction =/ UpdateStatus.do>
< button type =buttonvalue =Label>标签< / button>
< input type =textid =labelname =labelvalue =<%= label%>/>
< input type =buttononclick =TDISLabelForm.submit()value =Create>
< / form>
当我点击提交TDISLabelForm的创建按钮时,我想提交label的值。
感谢您的帮助。
>这是一个开始,让你在路上 函数submitLable(lblval){
var payLoad = document.forms ['TDISLabelForm']
.lab_no.value = document.forms ['ackForm']
.label.value; //将可见的值传递给隐藏表单
var request = requestObject();
request.open(POST,/createLabelTDIS.do,false); //将值发布到createLabelTDIS.do,以便像往常一样进行进一步处理。
request.send(payLoad);
函数requestObject(){
if(window.XMLHttpRequest)
return new XMLHttpRequest();
else if(window.ActiveXObject)
return new ActiveXObject(Msxml2.XMLHTTP);
else
抛出错误(无法创建HTTP请求对象);
}
< input type =buttononclick =submitLable(this)value =Create>
I want to submit a hidden form when a value is entered into a text input field that is part of another form.
<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>
I want to submit the value of "label" when I click on the Create button that submits TDISLabelForm. How can this be done?
Thanks for your help.
解决方案
This is a start, to get you on your way 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">
这篇关于提交隐藏表单HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!