How can I get the #value of a hidden form field in javscript as for hidden form
field I am unable to get its id in the (inspect element) html.
How can I extract the value(#value) for the field using ajax for the hidden fields


Try this:

$form['hidden'] = array(
 '#type' => 'hidden',
 '#value' => 'Your_value',
 '#attributes' => array('id' => array('your_id')),

Now using javascript or jquery you get the value of the hidden field.

In jquery: jQuery("#your_id").val();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.