0

<form id="pricecal">
    <input type="text" onchange="calprice()" class="form-control round-corner-fix datepicker" data-provide="datepicker" placeholder="Check in" value="" required />
    <input type="text" onchange="calprice()" class="form-control round-corner-fix datepicker" data-provide="datepicker" value="" placeholder="Check Out" required />
    <input type="hidden" onchange="calprice()" id="noroom" value="" name="room" />
    <input type="hidden" onchange="calprice()" id="noguest" value="" name="guest" />
</form>

my code perfectly works on input text but not on input type hidden i tried following ways i dont want to loop for every input

function calprice(){
    alert('Textarea Change');
}

$(document).on('change', 'form#pricecal input', function(){
    alert('Textarea Change'); 
});

$("form#pricecal input").bind("change", function() {
    alert('Textarea Change'); 
});
Morteza Asadi
  • 1,819
  • 2
  • 22
  • 39

2 Answers2

1

As you have bound event on the elements that can be triggered whenever you update your input's value:

$('input[type="hidden"]').trigger('change'); 

Put this line just after that line of code which causes the value change.

Jai
  • 74,255
  • 12
  • 74
  • 103
0

type=hidden These fields should not be rendered and provide a means for servers to store state information with a form. This will be passed back to the server when the form is submitted, using the name/value pair defined by the corresponding attributes. This is a work around for the statelessness of HTTP. Another approach is to use HTTP "Cookies".

Refer this link

Community
  • 1
  • 1