【发布时间】:2021-05-17 02:42:53
【问题描述】:
我已经全选并删除了复选框的所有按钮。你可以看到下面的代码。但是错误是他应该选择所有选项(不是复选框中的所有选项。)为什么复选框不选择所有选项?缺什么
详情 https://www.wix.com/velo/forum/community-discussion/why-doesn-t-the-select-all-button-select-all [![在此处输入图片描述][1]][1]
我的代码
export function CountrySelectAllt_click(event) {
// number of items in checkbox group
let totalItems = $w('#checkboxt1'+ ", " +'#checkboxt2'+ ", " +'#checkboxt3'+ ", "
+'#checkboxt4').options.length;
// initiate a newIndices array to hold all indices
let newIndices = [];
for (var i = 0; i < totalItems; i++) {
newIndices.push(i);
}
console.log(newIndices);
$w('#checkboxt1').selectedIndices = newIndices;
$w('#checkboxt2').selectedIndices = newIndices;
$w('#checkboxt3').selectedIndices = newIndices;
$w('#checkboxt4').selectedIndices = newIndices;
}
export function CountrySelectAlltreset_click(event) {
// number of items in checkbox group
let totalItems = $w('#checkboxt1'+ ", " +'#checkboxt2'+ ", " +'#checkboxt3'+ ", "
+'#checkboxt4').options.length;
// initiate a newIndices array to hold all indices
let newIndices = [];
for (var i = 0; i < totalItems; i++) {
newIndices.push(i);
}
console.log(newIndices);
$w('#checkboxt1').selectedIndices = [];
$w('#checkboxt2').selectedIndices = [];
$w('#checkboxt3').selectedIndices = [];
$w('#checkboxt4').selectedIndices = [];
}
[1]: https://i.stack.imgur.com/mQBT8.jpg
【问题讨论】:
标签: javascript select checkbox velo