htmlayout下拉组合框联动
By
codex
at 2020-11-02 • 2人收藏 • 2187人看过
//动态下拉组合框 import win.ui; /*DSG{{*/ var winform = win.form(text="下拉组合框联动";right=420;bottom=293) winform.add() /*}}*/ import console import web.layout; wbLayout = web.layout(winform); wbLayout.html = /* <meta charset="utf-8" /> <p>省份:<select #province size=1></select></p> <p>城市:<select #city size=1><option value="0" >无选择</option></select></p> */ dataBind = function(id, data){ //select第三个子节点 <popup> 的子节点才是 <option> 节点 var ele = wbLayout.queryEle(id).child(3); var n = ele.childCount() //清空 <option> 节点 for(i=n;1;-1) ele.child(i).delete() // 下面绑定data表 for(i=1;#data;1){ ele.printf("<option value='%d'>%s</option>", i, data[i]) } // 默认选中第一个选项 wbLayout.queryEle(id).child(1).innerText = data[1] ele.child(1).state.checked = true } var city = { ["无选择"] = {"无选择"}; ["江苏省"] = {"南京市";"苏州市";"无锡市";"常州市"}; ["浙江省"] = {"杭州市";"宁波市";"温州市";"绍兴市"}; ["广东省"] = {"广州市";"深圳市";"珠海市";"东莞市"}; }; dataBind( "#province", {"无选择";"江苏省";"浙江省";"广东省"} ) var pSelect = wbLayout.queryEle("#province") pSelect.onSelectSelectionChanged = function (ltTarget,ltOwner,reason,behaviorParams) { var ltOption = ..web.layout.element( behaviorParams.he ) dataBind("#city", city[ltOption.value]) } pSelect.attachEventHandler() winform.show(); win.loopMessage();
6 个回复 | 最后更新于 2020-11-03
登录后方可回帖
select 实际渲染出来的节点是上面这个样子的