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
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
Give your repeating section the class: myrepclasss
Give your check box the class: checkbox in both locations below
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);
}
});
}
}
Wonderful! Parker, It worked. Thanks for the help. Really appreciated
Sojan
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
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);
}
});
}
}
Hi Parker,
It unchecked all the rows, and the selected one (the last selection) is also unchecked.
Regards,
sojan
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.
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
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.