English 中文(简体)
将2个 j带合在一起
原标题:Combining 2 jquery scripts to work together

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);
            }
最佳回答
问题回答

将第二份档案中的职能放在文件准备就绪(窗口一级)中。 此时,这些文件仅涉及文件准备活动。

然后,你可以把职能从任何地方传到来(尽管你可能希望将其关闭)。 由于职能首先得到评价,因此没有按顺序排列档案。

由于业绩原因,最好将这一法典列入一个档案。 如果可能的话,你就可以把职能与守则放在一份文件中。 准备就绪。 这也许是最佳解决办法。





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签