我有这2个脚本,问题是仅当#hotel状态改变时才调用函数检查。 如何使功能检查运行,并在#hotel的情况下不会更改。结合2个jQuery脚本一起工作
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); }
你是如何决定何时运行'检查()'函数时'#hotel'输入没有变化?它是否提交或您有更新按钮? – Mottie 2010-04-28 17:09:04
这些是我想合并的两个脚本。 酒店是一个选择框,它影响两个输入框中的值(从,到) 第二个脚本,尽快两个输入框有值我将这些值传递给一个PHP文档并返回一些HTML。 我想第二个脚本从第一个脚本独立运行。 现在,第二个脚本只在#hotel状态更改时才运行。 谢谢! – Nikos 2010-04-28 17:17:56
在这里你可以看到问题http://jsfiddle.net/nNFMX/ – Nikos 2010-04-28 17:32:27