The case :
<form id='frm' name ='frm' action='test.php'>
<div style='display:non开发者_如何学JAVAe'>
<input type='text' name='name' value ='' />
</div>
<input type='submit' value='Submit' />
</form>
For example , How can i submit the from given above with its inputs ? Issue : The "name" input wont be passed !
Programatically, you can just trigger the submit
event on the form element:
$('#frm').submit();
Edit: Actually, after reading your markup more carefully, you are using an input
named name
, this element can cause "clashing" problems with the form's name attribute.
Consider changing the name of your input.
See also:
- Unsafe Names for HTML Form Controls
As a user, you'd just click the submit button. The visibility of a form element doesn't change the fact that it gets submitted with the form.
Programmatically:
document.getElementById('frm').submit();
If you're not trying to show the input, why not use type="hidden" and dispense with the style?
document.getElementById('frm').submit();
Here is how to submit hidden variables in a FORM:
<input type='hidden' name='name' value ='' />
精彩评论