Click here to Skip to main content
15,891,248 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi there! Here is my code:
HTML:
HTML
<select id="term" name="form_select">
    <option value="0">Choose term</option>
    <option value="1">Month</option>
    <option value="2">Week</option>
    <option value="3">Day</option>
</select>
<select id="season" name="form_select">
    <option value="0">Choose season</option>
    <option value="1">Low</option>
    <option value="2">Hight</option>
    <option value="3">Peak</option>
</select>

tr_ad_lowmonth
tr_ad_lowweek
tr_ad_lowday
tr_ad_hightmonth
tr_ad_hightweek
tr_ad_hightday
tr_ad_peakmonth
tr_ad_peakweek
tr_ad_peakday


JS:

JavaScript
$('#term, #season').on('change', function() {
 $('div[id^="ad_"]:gt(3)').css("display","none");

      var term   = $.trim( $('#term :selected').text().toLowerCase() ),
      season = $.trim( $('#season :selected').text().toLowerCase() );
 if($('#term :selected').val() > 0 && $('#season :selected').val() > 0)   {
          var $sel = '#ad_' + season + term;
          $($sel).css("display","block");

   }

});


CSS:

CSS
#ad_lowmonth,
#ad_lowweek,
#ad_lowday,
#ad_hightmonth,
#ad_hightweek,
#ad_hightday,
#ad_peakmonth,
#ad_peakweek,
#ad_peakday {
display:none;
}


It works perfect in Feedle , but don't work on my website . I don't know why! Can somebody help me? Thank you!
Posted
Comments
Nirav Prabtani 10-Jun-14 9:10am    
what is error in inspect element??
Member 10875484 11-Jun-14 2:26am    
No errors
Brian A Stephens 10-Jun-14 15:36pm    
You don't have any #ad_whatever DIVs in your HTML. Where are they?
Member 10875484 11-Jun-14 2:25am    
No, it is there... :)
Member 10875484 11-Jun-14 2:29am    
Ok, i resolve it and corrected JS block, thank you for help guys!

Ok then, check whether have you added required js libraries into your context ? On Fiddle you have added jQuery 2 (edge) and jQuery UI 1.10.3.Check that. :)

AND also $(document).ready(function() {} method.
 
Share this answer
 
v2
Comments
Member 10875484 10-Jun-14 15:50pm    
It works fine with jquery 1.8.3 and jQuery UI 1.9.2 on Feedle, and i tested it on different libsraies, and no effect. Please, what do you mean AND also $(document).ready(function() {} method?
Solution:

JavaScript
$(function () {
     $('#term, #season').on('change', function () {
         $('div[id^="ad_"]:gt(3)').css("display", "none");

         var term = $.trim($('#term :selected').text().toLowerCase()),
             season = $.trim($('#season :selected').text().toLowerCase());
         if ($('#term :selected').val() > 0 && $('#season :selected').val() > 0) {
             var $sel = '#ad_' + season + term;
             $($sel).css("display", "block");

         }

     });
 });
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900