开发者

Submitting hidden forms HTML

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">
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜