how to let a form field be hidden and at the same time the value be able to acces the id using javascript? 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' =&gt; 'hidden',
 '#value' =&gt; 'Your_value',
 '#attributes' =&gt; array('id' =&gt; array('your_id')),
);


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

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