cancel
Showing results for 
Search instead for 
Did you mean: 
lukas_man
Nintex Newbie

Nintex Forms 2010 Javascript/Jquery action stop working in if statement

Jump to solution

Hello everyone,

I got my code working while testing one action at a time. At the end, when I combined everything, one of the actions stopped working for some reason...

Let me explain.

1) deselects all checked boxes within a checkbox:

NWF$('.g9dw input:checkbox').not(this).prop('checked', this.checked); -- and this line works alone

2) test script - works!

NWF$(document).ready(function() {
   var v1 = NWF$('#' + igchq + ' input:checked').val();
   var validated = true;

   alert(v1);
   if(v1 == "HQ"){
      alert('success');
   }
}) 

3) final script combined. I only include deselect checkbox line inside if statement. DOES'T WORK. and I cannot understand why...

NWF$(document).ready(function() {
   var v1 = NWF$('#' + igchq + ' input:checked').val();
   var validated = true;

   alert(v1);
   if(v1 == "HQ"){

      alert('success');
      NWF$('.g9dw input:checkbox').not(this).prop('checked', this.checked);
   }
}) 

Could any of you explain me why... ?


Thank you all in advance.

Labels: (3)
0 Kudos
Reply
2 Replies
Highlighted
emha
Nintex Newbie

Re: Nintex Forms 2010 Javascript/Jquery action stop working in if statement

Jump to solution

likely, it's because of 'this'.

this has different meaning/value  in different contexts

not sure how you tested point 1), but within the ready event 'this' point to current document.

what's 'this.checked'? where do you set a value to this.checked property/variable?

use rather

.....prop('checked', true/false);‍‍

second appearance of 'this' in .not(this) sounds to me suspicious as well. what should it rule out?

I would say it should be removed.

or define correct selector what objects 'checked' property shouldn't be set for.

Reply
lukas_man
Nintex Newbie

Re: Nintex Forms 2010 Javascript/Jquery action stop working in if statement

Jump to solution

Marian,

Thank you! Now I see really my bad with using 'this'... I agree with your comments Smiley Happy

0 Kudos
Reply