JQuery add hidden element to form programmatically

Posted by vanzylv on Stack Overflow See other posts from Stack Overflow or by vanzylv
Published on 2010-04-08T15:32:42Z Indexed on 2010/04/08 17:43 UTC
Read the original article Hit count: 216

Filed under:
|

Hi Guys

This is really getting to me now.I have a form that loads when the page loads.In my jquery 'ready' function I append a hidden to that form like so :

$("<input id='thehidden' type='hidden' name='thehidden' value='hiddenval'>").appendTo("#MenuForm")

When I check the form content with firebug i can see the element is added.

["$(\"#MenuForm\").children()"] is [div, input#thehidden hiddenval]

All good so far.When I submit this form and try and read the elemet again,i can't get the value of the new hidden val I added.

alert($('#thehidden').val())

is undefined

Any help would be appreciated

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about JavaScript