我在一个页面中有两个表单,在提交表单2之前是否有一种方法可以从表单1获取选定的值,因此我可以在一个表中将两个值(表单1的选定值和表单2的输入框值)插入到单个表中。需要帮忙
HTML:
<form name="form1" id="form1" method="POST" action="">
<table>
<tr>
<td><select name="type">
<option value="">Select Type</option>
<option value="val1" selected="selected">val1</option>
<option value="val2">val2</option>
</select></td>
</tr>
</table>
</form>
<form name="form2" id="form2" method="POST" action="">
<table>
<tr>
<td><input type="text" id="test1"></td>
<td><input type="submit" name="go" value="go" /></td>
</tr>
</table>
</form>
1. just use a hidden field in form two and when ever the select box changes assign the changedvalue to the hidden field
$('#selectbox').on('change',function() {
$('#hiddenfield').val($('#selectbox').val());//HIDDEN FIELD PLACED IN FORM 2
});
by this method you could get the form 1 value to form 2 submit.
您可以使用这个小提琴:http : //jsfiddle.net/hoja/jw3y9ky7/
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句