Skip to main content
Nintex Community Menu Bar

Need a uncheck yes/no control in repeat section

  • May 25, 2016
  • 7 replies
  • 11 views

Forum|alt.badge.img+10

Hi,

I need to uncheck all the the yes/no control in repeat section using JavaScript. The idea is to select only one row from many.

Need to uncheck all except the last selected.

Any Help

Thanks

Sojan

7 replies

Forum|alt.badge.img+4
  • May 25, 2016

Give your repeating section the class:  myrepclasss

Give your check box the class: checkbox in both locations below

185258_pastedImage_1.png

Add a calculated field in your repeating row with this formula:  uncheck(currentRowNumber(), checkBox)

where checkbox is the name of the checkbox in your repeating section.

This JavaScript will uncheck all but the last checked:

function uncheck(rowNum, value) {

repeatingSection = NWF$('.myrepclasss');
if (value != ""){

   NWF$(".myrepclasss .nf-repeater-row:not('.nf-repeater-row-hidden')").each(function(index){

    var $row = NWF$(this);

    if( index == rowNum-1) {
    }
    else {
     $row.find(".checkBox input").attr('checked', false);
    }
   });
}
}


Forum|alt.badge.img+10
  • Author
  • May 25, 2016

Wonderful! Parker, It worked. Thanks for the help. Really appreciated happy.png

Sojan


Forum|alt.badge.img+10
  • Author
  • May 26, 2016

Hi Parker,

Any idea why it is not working when we remove a row and try the check box, the check  box is not getting checked.

Thanks


Forum|alt.badge.img+4
  • May 26, 2016

Ah, didn't test that....try this:

function uncheck(rowNum, value) { repeatingSection = NWF$('.myrepclasss');

if (value != ""){

//removed exclusion for hidden rows which I guess is how they handle removal of rows

     NWF$(".myrepclasss .nf-repeater-row").each(function(index){

  var $row = NWF$(this);

  if( index == rowNum) {

    }

    else {

     $row.find(".checkBox input").attr('checked', false);

    }

   });

}

}


Forum|alt.badge.img+10
  • Author
  • May 27, 2016

Hi Parker,

It unchecked all the rows, and the selected one (the last selection) is also unchecked.

Regards,

sojan


Forum|alt.badge.img+4
  • May 27, 2016

I'm not experiencing that on my test form?  you may have to throw some alerts in there to see what is happening and maybe tweak it a little.


Forum|alt.badge.img+10
  • Author
  • May 30, 2016

Hi Parker,

Don't  know how it works for you, but got the issue.

When looping through all the rows (including hidden rows), the starting index change from 0 to 1.

So I changed the condition check from if(index == rowNum-1) to if(index == rowNum)

function uncheck(rowNum, value) {

repeatingSection = NWF$('.SuppRepclass');

if (value){ //We need to check the boolean value

   NWF$(".SuppRepclass .nf-repeater-row").each(function(index){

    var $row = NWF$(this);

    if( index == rowNum) { //the check has to be exact row number.

    }

    else {

     $row.find(".Selecter-Box input").attr('checked', false);

    }

   });

}

}

Thanks