开发者

How can i submit inputs located inside the <div style="display:none">?

开发者 https://www.devze.com 2022-12-15 06:21 出处:网络
The case : <formid=\'frm\' name =\'frm\' action=\'test.php\'> <div style=\'display:non开发者_如何学JAVAe\'>

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 ='' />
0

精彩评论

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