Editing hidden form field with Jquery in Drupal
Currently I'm trying to edit a hidden form with the command:
jQuery(document).ready(function(){
jQuery("#test").val("hi");
});
This is inside an inline drupal_add_js.
When the form 'test' is a normal textfield, this works. When it is hidden, this does not work. I'm currently using Drupal 7's webform module to create the form. I've read dozens of stackoverflow questions regarding populating hidden fields but I haven't gotten anything to work. I'm hoping that its just something that is syntactically different for hidden fields, but most likely its somethin开发者_开发百科g in drupal I don't know about.
Try instead:
jQuery("input[name=test]").val("hi");
i am really not aware of coding style in Drupal
, but if u want i can suggest you in basic jQuery way, hope this will b helpful for u :)
HTML
<form name="testform" method="POST" action ="#">
<input type="hidden" name="hiddenInput" id="hiddenInput">
Hii
<input type="submit" name="Go" >
</form>
jQuery
$('form').submit{(
alert('Submitted');
var hid=$('input[type="hidden"]').val('HiddenText');
alert(hid.val);
return false;
});
精彩评论