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(":checkbox[value='ALB']").attr("checked",true);
NWF$("#" + Site).find(":checkbox[value='ECH']").attr("checked",true);
NWF$("#" + Site).find(":checkbox[value='OCA']").attr("checked",true);
NWF$("#" + Site).find(":checkbox[value='HDQ']").attr("checked",true);
NWF$("#" + Site).find(":checkbox[value='AUR']").attr("checked",true);
NWF$("#" + Site).find(":checkbox[value='MTC']").attr("checked",true);
NWF$("#" + Site).find(":checkbox[value='HAM']").attr("checked",true);
NWF$("#" + Site).find(":checkbox[value='WCW']").attr("checked",true);
NWF$("#" + Site).find(":checkbox[value='BAR']").attr("checked",true);
NWF$("#" + Site).find(":checkbox[value='CLE']").attr("checked",true);
NWF$("#" + Site).find(":checkbox[value='HER']").attr("checked",true);
NWF$("#" + Site).find(":checkbox[value='BRN']").attr("checked",true);
NWF$("#" + Site).find(":checkbox[value='DEC']").attr("checked",true);
NWF$("#" + Site).find(":checkbox[value='LVC']").attr("checked",true);
NWF$("#" + Site).find(":checkbox[value='CHA']").attr("checked",true);
NWF$("#" + Site).find(":checkbox[value='DEN']").attr("checked",true);
NWF$("#" + Site).find(":checkbox[value='MID']").attr("checked",true);
}
Solved! Go to Solution.
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")[1]);
}
});
}
}});
function delay(t) {
return new Promise(function (resolve) {
setTimeout(resolve, t)
});
}});