function with input hidden jquery code example
Example 1: jquery create input hidden
$('<input>').attr({
type: 'hidden',
id: 'foo',
name: 'bar'
}).appendTo('form');
Example 2: hidden jquery
$('#yourid').attr('hidden', false);
$('#yourid').attr('hidden', true);
Example 3: onchange value in hidden input
//in the HTML: <input id="myValue" type="hidden" name="myValue" value="">
$(function(){
var $hello= $('[id$="myValue"]');
$hello.on("change", function(){ //bind() for older jquery version
alert('hey');
}).triggerHandler('change'); //could be change() or trigger('change')
});
//Then, each time you change the value of targeted hidden inputs, trigger handler, e.g:
$('#myValue').val('the new value').triggerHandler('change');
//That's because onchange event is not fired automatically changing its value programatically.