Denys Medynskyi
Denys Medynskyi

Reputation: 2353

How to make appropriate action for appropriate select option(using DropKick)?

I'm making report page and want to show appropriate list for appropriate type of report.

I have monhly, yearly and summary reports.

Here is my select, that I want to react on:

  <div class="select">
        <select name="type" class="default" tabindex="7">
          <option value="monthly">Monthly report</option>
          <option value="yearly">Yearly report</option>
          <option value="summary">Summary</option>
        </select>
  </div>

Here is example from DropKick:

    $('.change').dropkick({
   change: function (value, label) {
   alert('You picked: ' + label + ':' + value);
  }
});

I want to use something like:

 $('.default').dropkick({
 change: function (value, label) {
if(value=="monthly"){
    $(".monthly").show();
  }
 else if(value="yearly"){
   $("#yearly").show();
 }
 }
});

but it didn't work. I have in my view hidden div, with all these selects:

 <div class="types">
       <div class="monthly">
          ...
        </div>
      <div class="yearly">
        ...
      </div>
  </div>

Can anyone help me ?

Upvotes: 0

Views: 144

Answers (1)

Dogbert
Dogbert

Reputation: 222318

$("#yearly").show();

should be

$(".yearly").show();

as that div uses yearly class, not id.

Plus you should probably hide the other div before showing one, if you only want one to be showing at once.

Just noticed one more thing

else if(value="yearly"){

should be

else if(value=="yearly"){
             ^ this

Upvotes: 2

Related Questions