I have these 2 scripts and the problem is that function check is called only if #hotel state is changed. How can I make function check run and in the case of #hotel doesn t change.
var hotelMap = { hotel_a: 15, hotel_b: 5, hotel_c: 10 }; //Edw mporeis na allazeis to release period gia kathe ksenodoxeio $(function() { $( #hotel ).change(function() { var selectVal = $( #hotel :selected ).val(); $("#from, #to").datepicker("option", "minDate", hotelMap[selectVal]); }); var dates = $( #from, #to ).datepicker({ defaultDate: "+1w", changeMonth: true, dateFormat: yy-m-d , minDate: 15,//Episis edw prepei na mpainei to release period tou prwtou stoixeiou sth lista numberOfMonths: 3, onSelect: function(selectedDate) { var option = this.id == "from" ? "minDate" : "maxDate"; var instance = $(this).data("datepicker"); var date = $.datepicker.parseDate(instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings); dates.not(this).datepicker("option", option, date); } }); });
$(document).ready(check); function check(){ $( #from, #to, #hotel ).bind( change , update); $( #wait ).show(); } function update(){ var from=$( #from ).attr( value ); var to=$( #to ).attr( value ); var hotel=$( #hotel ).attr( value ); $.get( get_availability.php , {from: from, to:to, hotel:hotel}, show); } function show(avail){ $( #wait ).hide(); $( #availability ).html(avail); }