Skip to main content

Hi,

i am new to JavaScript and am trying to find a way to do a select all on a Choice Control that is in a repeating section.

I have it working for only the first row if you add another row the button doesn't work for the second row. Is there a way to have a select all for all the choice buttons in the repeating section not just the first row?

Here is my javascript code that works for the first row

function selectAll()
{NWF$("#" + Site).find(":checkboxovalue='ALB']").attr("checked",true);
NWF$("#" + Site).find(":checkboxovalue='ECH']").attr("checked",true);
NWF$("#" + Site).find(":checkboxovalue='OCA']").attr("checked",true);
NWF$("#" + Site).find(":checkboxovalue='HDQ']").attr("checked",true);
NWF$("#" + Site).find(":checkboxovalue='AUR']").attr("checked",true);
NWF$("#" + Site).find(":checkboxovalue='MTC']").attr("checked",true);
NWF$("#" + Site).find(":checkboxovalue='HAM']").attr("checked",true);
NWF$("#" + Site).find(":checkboxovalue='WCW']").attr("checked",true);
NWF$("#" + Site).find(":checkboxovalue='BAR']").attr("checked",true);
NWF$("#" + Site).find(":checkboxovalue='CLE']").attr("checked",true);
NWF$("#" + Site).find(":checkboxovalue='HER']").attr("checked",true);
NWF$("#" + Site).find(":checkboxovalue='BRN']").attr("checked",true);
NWF$("#" + Site).find(":checkboxovalue='DEC']").attr("checked",true);
NWF$("#" + Site).find(":checkboxovalue='LVC']").attr("checked",true);
NWF$("#" + Site).find(":checkboxovalue='CHA']").attr("checked",true);
NWF$("#" + Site).find(":checkboxovalue='DEN']").attr("checked",true);
NWF$("#" + Site).find(":checkboxovalue='MID']").attr("checked",true);
}

I see you have 'Select All' out of repeating section (row).

so the question, how should it behave if there are multiple row already created in repeating section? should it select all the choice options on all the rows?

if not, how do you identify which row should it work for?


I think that's my issue.. When I built (Copied from other posts) the function I didn't think about the repeating section until the user complained lol.

I would like the select all button hit one time and select all the choice options in all rows


ok, then I think following might help you

function selectAll() {
  NWF$('.rsClass .nf-repeater-row:not(.nf-repeater-row-hidden) .SiteChoiceClass input:checkbox').prop("checked",true);
}‍‍‍

rsClass is CSS class configured for repeating section

SiteChoiceClass is CSS class configured for 'Site' choice

‌ 


WOW!!! Thanks that is better than I could have hoped and a lot simpler...


How can I get the following code (adapted from another thread) to work in subsequent rows in a repeating section?

NWF$(document).ready(function () {

NWF$("#" + ResponsibleBU).change(function () {
   NWF$("#" + ResponsibleBUEmailAddress).change();
});

NWF$("#" + ResponsibleBUEmailAddress).change(function () {

var ResponsibleBUEmailAddressId = ResponsibleBUEmailAddress.substring(0, ResponsibleBUEmailAddress.length - 4);
var len = NWF$("#" + ResponsibleBUEmailAddressId).find("option").length;
if (len >= 2) {
   return delay(500).then(function () {
   NWF$("#" + ResponsibleBUEmailAddressId).prop('selectedIndex', 1).change();
   NWF$("input#" + ResponsibleBUEmailAddressId).val(NWF$("#" + ResponsibleBUEmailAddressId).find("option")"1]);
});
}
else {

   while (i < 10 && len == 1) {
   i++;
   return delay(500).then(function () {
        len = NWF$("#" + ResponsibleBUEmailAddressId).find("option").length;
        if (len >= 2) {
            NWF$("#" + ResponsibleBUEmailAddressId).prop('selectedIndex', 1).change();
            NWF$("input#" + ResponsibleBUEmailAddressId).val(NWF$("#" + ResponsibleBUEmailAddressId).find("option")b1]);
        }
    });
}
}});
function delay(t) {
       return new Promise(function (resolve) {
            setTimeout(resolve, t)
       }); 
  }});


Hi ‌,

this code is designed for lookup controls.

this thread deals with choice controls instead.

from your other recent posts I've feeling that you're looking for a solution for choices as well. I'd suggest to start your own new question and describe what exactly you need and what's your setup.


Reply