1

enter image description here

In 'Leave Type' dropdown there are 3 fields casual leave, maternity leave. 1,2,3,4,5... these are the date fields , I have converted these fields into days.

I want to ensure that if 'Leave Type' selected index is 0 then I couldn't check the check box.

  function(LeaveTypeSelectedIndex,chk)
   {
      if(LeaveTypeSelectedIndex==0)
      {

         chk..checked = false;
      }
   }

I have tried but i'm not going to my destination. how do i do that. And Thanks in Advance

Joy Acharya
  • 680
  • 1
  • 10
  • 18
  • Seems a rather complicated up for entering two dates and why a person is not at work – Ed Heal Jun 14 '15 at 09:15
  • If you mean you want to disable the checkboxes, you should look at the `disabled` property instead of the `checked` property. Setting `checked` to false will risk erasing your user's checked dates if they accidentally revert to the first (default) choice. – Terry Jun 14 '15 at 09:19

2 Answers2

2

I think the way you try to uncheck the checkbox is the problem. See https://stackoverflow.com/a/17420580/524913 .

Basically, this is what you need to do:

$(chk).attr('checked', false);
Community
  • 1
  • 1
yamass
  • 765
  • 5
  • 14
1

Not sure but you give no conditions to your if statement... and also I think you need it to be a variable...

function($LeaveTypeSelectedIndex,$chk) {
    if($LeaveTypeSelectedIndex==0) {
         $chk.checked = false;
    }
}
Yann Poiré
  • 134
  • 6