tags:

views:

89

answers:

5

The case :

<form  id='frm' name ='frm' action='test.php'>
 <div style='display:none'>
 <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 !

+1  A: 

document.getElementById('frm').submit();

Raveren
+6  A: 

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:

CMS
+3  A: 

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();
nickf
+2  A: 

If you're not trying to show the input, why not use type="hidden" and dispense with the style?

Sir William
+1  A: 

Here is how to submit hidden variables in a FORM:

<input type='hidden' name='name' value ='' />
Kristoffer Bohmann