提交表单时,仅该表单中的字段会根据请求发送。
您可以只使用一种表单(包含所有字段),也可以使用Javascript,然后再提交以将值从一种表单复制到另一种表单的隐藏元素。
编辑: 这是一个小JS示例:
<!-- test.html --><html> <head> <script type="text/javascript"> function doCopyAndThenSubmit() { var sourceInput = document.getElementById("source"); //destination should be the hidden field, made it text to have a visual on the operation var destinationInput = document.getElementById("destination"); destinationInput.value = sourceInput.value; //watch the address bar after the OK alert("Did the copy, press OK for the submit"); document.forms["yourForm"].submit(); } </script> </head> <body> Add some text in source and change the value in the select<br/> <form action="test.html" method="GET" name="yourForm"> <select onchange="doCopyAndThenSubmit()"> <option value="x">some value</option> <option value="y">some other</option> </select> <br/>Source: <!-- id must be unique in the entire document (don't confound with name) --> <input name="src" id="source" type="text" value="" /> <br/>Destination: <input name="dest" id="destination" type="text" value="" /> </form> </body></html>通常,您将拥有具有相同值的name和id属性,以便于跟踪(而不是先按id然后按名称引用一次输入);我使用了不同的值来加强差异。当然,您将以一种形式出现源,而以另一种形式出现目的地。
<form name="form1" ...> ... <input name="source" id="source" type="text" value="" /></form><form name="form2" ...> ... <input name="destination" id="destination" type="hidden" value="" /></form>



