715 posts
  • Has sold $100+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
  • Located in Belgium
+1 more
Hy-Studio says

Hi!

I’m making a jquery script that get’s another file and sends parameters to it.

Here’s the way it should work (select option lists only):

  • user selects a depot number
  • an option list with years are displayed, user selects year
  • an option list with months are displayed, user selects month
  • an option list with days are displayed, user selects day

after selecting day they get a result with images (it’s for our intranet so I can’t show you a live version).

The problem lies when the user selects the year, I see in firebug that he gets the file which displays the months but then he gets the file where the years are displayed, so it’s like he’s getting two files instead of 1.

Strange thing is that this problem only occurs after selecting the depot, so this problem lies with selecting year, month and day and not the first option to select.

here’s my code:

$(document).ready(function(){

$('.selectDepot').live("change", function(){

            var depot = $(this).val();

            if( depot == 'Select Depot' ){

                $('.selectYear, .selectMonth, .selectDay, input.button').hide();

            }else{

                $.get('selectYear.php', { 'depot': depot }, function(data){
                    $('.imgDrop01').show().html(data);                    
                });

            }

        });

$('.selectYear').live("change", function(){

                    var depot = $(".selectDepot option:selected" ).val(),
                        year = $(this).val();

                    if(year == 'Select Year'){

                        $('.selectMonth, .selectDay, input.button').hide();

                    }else{
                        $.get('selectMonth.php', {'depot': depot, 'year': year}, function(data){
                            $('.imgDrop02').html(data);
                        });
                    }

                });

                $('.selectMonth').live("click", function(){

                    var depot = $(".selectDepot option:selected").val(),
                        year  = $(".selectYear option:selected").val(),
                        month = $(this).val();

                    if( month == "Select Month" ){

                        $('.selectDay, input.button').hide();

                    }else{
                        $.get("selectDay.php", {'depot': depot, 'year': year, 'month': month}, function(data){
                            $('.imgDrop03').html(data);
                        });
                    }

                });

}

jQuery code for the day isn’t finished yet.

Anyone an idea?

Thanks!

by
by
by
by
by
by