Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共2 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:请问在weui 內的复选列表项中如何限制选择的数目?

1楼
kennypalm 发表于:2023/10/11 22:13:00
请问在weui 內的复选列表项中如何限制选择的数目? 比如列表中有 10 项只能选 2 项 如何实现这个功能 ?

图片点击可在新窗口打开查看此主题相关图片如下:sp20231011_215004.jpg
图片点击可在新窗口打开查看

2楼
有点蓝 发表于:2023/10/12 10:10:00
httprequest

Dim wb As New weui
wb.AddForm("", "form1", "test.htm")
With wb.AddCheckGroup("form1", "rdg1", "浏览器")
    .Add("bw1", "Intenet Explorer").Attribute = "onclick=""setChecked(this)"""
    .Add("bw2", "Google Chorme").Attribute = "onclick=""setChecked(this)"""
    .Add("bw3", "FireFox").Attribute = "onclick=""setChecked(this)"""
    .Add("bw4", "Safari").Attribute = "onclick=""setChecked(this)"""
End With
With wb.AddButtonGroup("form1", "btg1", True)
    .Add("btn1", "确定", "submit")
End With

wb.AppendHTML("<script src='test.js' ></script>")
e.WriteString(wb.Build)

test.js文件
var checkValues = [];
function setChecked(e) {
    if (e.checked) {
        if (checkValues.length == 2) {
            e.checked = false;
            return;
        }
        else {
            checkValues.push(e.id);
            if (checkValues.length == 2) {
                for (let i = 1; i <= 4; i++) {
                    let rd = document.getElementById('bw' + i);
                    if (checkValues.indexOf('bw' + i) == -1)
                        rd.setAttribute("disabled", true);
                    else
                        rd.removeAttribute("disabled");
                }
            }
        }
    }
    else {
        checkValues.splice(checkValues.indexOf(e.id), 1);
        for (let i = 1; i <= 4; i++) {
            let rd = document.getElementById('bw' + i);
                rd.removeAttribute("disabled");
        }
    }
}
[此贴子已经被作者于2023/10/12 10:10:29编辑过]
共2 条记录, 每页显示 10 条, 页签: [1]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .02344 s, 2 queries.