Home » Javascript » Selecting one thing at a time with jquery,out of ideeas

Selecting one thing at a time with jquery,out of ideeas

Posted by: admin August 19, 2018 Leave a comment

Questions:

I have a table, automatically generated with Smarty. The table has some settings:

  • slice (number, it’s a wheel)
  • coupon (winning or losing)
  • slice label (basically if you win what you win, for example 20% off)
  • coupon code (20OFF, 50OFF etc)
  • slice color

Every element listed is a td. I need to write a function that disables the coupon code field if you mark the slice label as losing, I made a function, however it disables all of them. I can’t give each slice a certain class, they all have the same classes. couponType is the label, winning or losing and couponCode is the field I need to disable. Any ideas? Here’s what I’ve written so far:

$('.couponType').change(function(){
  if($(this).val() == 'losing') {                    
    $('.couponCode').closest('.couponCode').attr('disabled','disabled');
  } else {
    $('.couponCode').removeAttr('disabled');
  }
});
Answers: