以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  单选按钮全部选中问题  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=158092)

--  作者:刘林
--  发布时间:2020/11/7 15:24:00
--  单选按钮全部选中问题
Dim e As RequestEventArgs = args(0)
Dim wb As New WeUI
wb.InsertHTML("<script src=\'../mui/js/mui.min.js\'></script>")
wb.InsertHTML("<link href=\'../mui/css/mui.css\' rel=\'stylesheet\'/>")
wb.InsertHTML("<script Type=\'text/javascript\' charset=\'utf-8\'>mui.init();</script>")
wb.InsertHTML("</head>")
wb.InsertHTML("<body>")
wb.InsertHTML("<header class=\'mui-bar mui-bar-nav mui-bar-nav-bg\'>")
wb.InsertHTML("<a  id=\'icon-menu\' class=\'mui-action-back mui-icon mui-icon-left-nav mui-pull-left\'></a>")
wb.InsertHTML("<h1 class=\'mui-title\'>学生转出权限管理</h1>")
wb.InsertHTML("</header>")
wb.InsertHTML("<div class=\'mui-content\'>")
wb.AddPageTitle("","pageheader","","")
wb.AddToast("","t1", "正在上传",1) \'定义提示
wb.AddForm("","form1","jcsdsave.htm").attribute= """
Dim cmd As new SQLCommand
cmd.C
cmd.CommandText ="Se/ect [学校名称],[班级],[学生姓名],[身份证件号],[审核锁定],[_Identify] From {学生信息} where  [班级]=\'" & e.Cookies("bj") & "\' and [学校名称]=\'" & e.Cookies("userdw") & "\' and  [班级]=\'" & e.Cookies("bj") & "\' order by [学生姓名]"
Dim dt As DataTable =  cmd.ExecuteReader(True)
wb.insertHtml("form1", "<div style=\'maring:10px;display: inline-block;width:120px;\'><input Type=\'radio\' id= \'noall\' name=\'all\' value=\'noall\' >全部禁止转出</input></div><div style=\'maring-left:20px;display: inline-block;width:120px;\'><input Type=\'radio\' id=\'yesall\' name=\'all\' value=\'yesall\'>全部允许转出</input></div><div style=\'maring-left:20px;display: inline-block;width:120px;\'><input Type=\'radio\' id= \'choose\' name=\'all\' value=\'choose\' checked >选择授权转出</input></div>")
wb.InsertHTML("form1", "<Table border=1 cellspacing=0 style=\'width:100%;text-align:center;\'><tr style=height:45px;color:red;\'><td style=\'text-align:center;font-size: 15px;strong\'>序号</td><td style=\'text-align:center;font-size: 15px;strong\'>学生姓名</td><td style=\'text-align:center;font-size: 15px;strong\'>禁止转出</td><td style=\'text-align:center;font-size: 15px;strong\'>允许转出</td></tr>")
Dim i As Integer=1
For Each dr As DataRow In dt.DataRows
    If dr("审核锁定")=True
        wb.insertHtml("form1", "<tr style=\'height:45px;\'><td style=font-size:15px\' >" & i & "</td> <td style=font-size:15px\' ><a href=\'sdxsxx.htm?xssfzh=" & dr("身份证件号") & "\'>" & dr("学生姓名") & "</a></td><td><input type=\'radio\'  id=\'yes_" & dr("_Identify") & "\' name=\'radio1_" & dr("_Identify") & "\' value=\'yes_" & dr("_Identify") & "\' checked></td><td><input type=\'radio\' id= \'no_" & dr("_Identify") & "\' name=\'radio1_" & dr("_Identify") & "\' value=\'no_" & dr("_Identify") & "\' ></td></tr>")
    Else
        wb.insertHtml("form1", "<tr style=\'height:45px;\'><td style=font-size:15px\' >" & i & "</td> <td style=font-size:15px\' ><a href=\'sdxsxx.htm?xssfzh=" & dr("身份证件号") & "\'>" & dr("学生姓名") & "</a></td><td><input type=\'radio\'  id=\'yes_" & dr("_Identify") & "\' name=\'radio1_" & dr("_Identify") & "\' value=\'yes_" & dr("_Identify") & "\' ></td><td><input type=\'radio\' id= \'no_" & dr("_Identify") & "\' name=\'radio1_" & dr("_Identify") & "\' value=\'no_" & dr("_Identify") & "\'  checked ></td></tr>")
    End If
    i=i+1
Next
wb.insertHtml("form1", "</Table>")
wb.InsertHTML("form1","<button Type=\'submit\'  name=\'submit\'  style=\'position: fixed;left:50%;transform:translate(-50%);bottom:20px;z-index:5;weight:35px;width:35px;background-image:url(../tubiao/ok.png);width: 32px;height: 32px;background-repeat:no-repeat ;background-size:32px 32px; border: 0;background-color: transparent;\'></button>")
e.WriteString(wb.Build)
e.Handled=True


老师,请问我上面做的三个单选按钮我想在点全部允许转出时下面表格中的允许转出列的单选按钮就变为全部选中这种怎么写,谢谢

--  作者:有点蓝
--  发布时间:2020/11/7 16:06:00
--  
全部允许转出绑定onclick事件,调用js函数处理。在函数里查找遍历table里所有的单选按钮,设置其check属性。
可以使用querySelectorAll方法查找:https://www.runoob.com/jsref/met-document-queryselectorall.html
如:var x = document.querySelectorAll("td input[type=radio]"); 

至于怎么遍历和设置check属性,自行百度学习,这些都是js基础,既然都要自己使用原生的html做,都是必备的知识点
[此贴子已经被作者于2020/11/7 16:06:31编辑过]

--  作者:刘林
--  发布时间:2020/11/7 16:42:00
--  
Dim e As RequestEventArgs = args(0)
Dim wb As New WeUI
wb.InsertHTML("<script src=\'../mui/js/mui.min.js\'></script>")
wb.InsertHTML("<link href=\'../mui/css/mui.css\' rel=\'stylesheet\'/>")
wb.InsertHTML("<script Type=\'text/javascript\' charset=\'utf-8\'>mui.init();</script>")
wb.InsertHTML("</head>")
wb.InsertHTML("<body>")
wb.InsertHTML("<header class=\'mui-bar mui-bar-nav mui-bar-nav-bg\'>")
wb.InsertHTML("<a  id=\'icon-menu\' class=\'mui-action-back mui-icon mui-icon-left-nav mui-pull-left\'></a>")
wb.InsertHTML("<h1 class=\'mui-title\'>在校学生转出权限管理</h1>")
wb.InsertHTML("</header>")
wb.InsertHTML("<div class=\'mui-content\'>")
wb.AddPageTitle("","pageheader","","")
wb.AddToast("","t1", "正在上传",1) \'定义提示
wb.AddForm("","form1","jcsdsave.htm").attribute= """
Dim cmd As new SQLCommand
cmd.C
cmd.CommandText ="Se/ect [学校名称],[班级],[学生姓名],[身份证件号],[审核锁定],[_Identify] From {学生信息} where  [班级]=\'" & e.Cookies("bj") & "\' and [学校名称]=\'" & e.Cookies("userdw") & "\' and  [班级]=\'" & e.Cookies("bj") & "\' order by [学生姓名]"
Dim dt As DataTable =  cmd.ExecuteReader(True)
wb.insertHtml("form1", "<div style=\'maring:10px;display: inline-block;width:120px;\'><input Type=\'radio\' id= \'noall\' name=\'all\' value=\'noall\' >全部禁止转出</input></div><div style=\'maring-left:20px;display: inline-block;width:120px;\'><input Type=\'radio\' id=\'yesall\' name=\'all\' value=\'yesall\' >全部允许转出</input></div><div style=\'maring-left:20px;display: inline-block;width:120px;\'><input Type=\'radio\' id= \'choose\' name=\'all\' value=\'choose\' checked >选择授权转出</input></div>")
wb.InsertHTML("form1", "<Table border=1 cellspacing=0 style=\'width:100%;text-align:center;\'><tr style=height:45px;color:red;\'><td style=\'text-align:center;font-size: 15px;strong\'>序号</td><td style=\'text-align:center;font-size: 15px;strong\'>学生姓名</td><td style=\'text-align:center;font-size: 15px;strong\'>禁止转出</td><td style=\'text-align:center;font-size: 15px;strong\'>允许转出</td></tr>")
Dim i As Integer=1
For Each dr As DataRow In dt.DataRows
    If dr("审核锁定")=True
        wb.insertHtml("form1", "<tr style=\'height:45px;\'><td style=font-size:15px\' >" & i & "</td> <td style=font-size:15px\' ><a href=\'sdxsxx.htm?xssfzh=" & dr("身份证件号") & "\'>" & dr("学生姓名") & "</a></td><td><input type=\'radio\' class=\'aa\'  id=\'yes_" & dr("_Identify") & "\' name=\'radio1_" & dr("_Identify") & "\' value=\'yes_" & dr("_Identify") & "\' checked></td><td><input type=\'radio\' class=\'ab\' id= \'no_" & dr("_Identify") & "\' name=\'radio1_" & dr("_Identify") & "\' value=\'no_" & dr("_Identify") & "\' ></td></tr>")
    Else
        wb.insertHtml("form1", "<tr style=\'height:45px;\'><td style=font-size:15px\' >" & i & "</td> <td style=font-size:15px\' ><a href=\'sdxsxx.htm?xssfzh=" & dr("身份证件号") & "\'>" & dr("学生姓名") & "</a></td><td><input type=\'radio\' class=\'aa\'  id=\'yes_" & dr("_Identify") & "\' name=\'radio1_" & dr("_Identify") & "\' value=\'yes_" & dr("_Identify") & "\' ></td><td><input type=\'radio\' class=\'ab\' id= \'no_" & dr("_Identify") & "\' name=\'radio1_" & dr("_Identify") & "\' value=\'no_" & dr("_Identify") & "\'  checked ></td></tr>")
    End If
    i=i+1
Next
wb.insertHtml("form1", "</Table>")
wb.InsertHTML("form1","<button Type=\'submit\'  name=\'submit\'  style=\'position: fixed;left:50%;transform:translate(-50%);bottom:20px;z-index:5;weight:35px;width:35px;background-image:url(../tubiao/ok.png);width: 32px;height: 32px;background-repeat:no-repeat ;background-size:32px 32px; border: 0;background-color: transparent;\'></button>")
wb.InsertHTML("form1", "<script>Function myFunction1(){var x = document.querySelectorAll(\'.ab\');  var i;for (i = 0; i < x.length; i++) {x[i].checked = \'true\';}</script>")
e.WriteString(wb.Build)
e.Handled=True


老师,你这样做了没反应,表中允许转出列的单选没动,请帮看下哪里还有问题

--  作者:有点蓝
--  发布时间:2020/11/7 16:49:00
--  
只是定义了一个函数,没有看到调用这个函数的代码

另外注意大小写:wb.InsertHTML("form1", "<script>function 

最后,添加js最好使用AppendHTML

--  作者:刘林
--  发布时间:2020/11/7 16:55:00
--  
Dim e As RequestEventArgs = args(0)
Dim wb As New WeUI
wb.InsertHTML("<script src=\'../mui/js/mui.min.js\'></script>")
wb.InsertHTML("<link href=\'../mui/css/mui.css\' rel=\'stylesheet\'/>")
wb.InsertHTML("<script Type=\'text/javascript\' charset=\'utf-8\'>mui.init();</script>")
wb.InsertHTML("</head>")
wb.InsertHTML("<body>")
wb.InsertHTML("<header class=\'mui-bar mui-bar-nav mui-bar-nav-bg\'>")
wb.InsertHTML("<a  id=\'icon-menu\' class=\'mui-action-back mui-icon mui-icon-left-nav mui-pull-left\'></a>")
wb.InsertHTML("<h1 class=\'mui-title\'>在校学生转出权限管理</h1>")
wb.InsertHTML("</header>")
wb.InsertHTML("<div class=\'mui-content\'>")
wb.AddPageTitle("","pageheader","","")
wb.AddToast("","t1", "正在上传",1) \'定义提示
wb.AddForm("","form1","jcsdsave.htm").attribute= """
Dim cmd As new SQLCommand
cmd.C
cmd.CommandText ="Se/ect [学校名称],[班级],[学生姓名],[身份证件号],[审核锁定],[_Identify] From {学生信息} where  [班级]=\'" & e.Cookies("bj") & "\' and [学校名称]=\'" & e.Cookies("userdw") & "\' and  [班级]=\'" & e.Cookies("bj") & "\' order by [学生姓名]"
Dim dt As DataTable =  cmd.ExecuteReader(True)
wb.insertHtml("form1", "<div style=\'maring:10px;display: inline-block;width:120px;\'><input Type=\'radio\' id= \'noall\' name=\'all\' value=\'noall\' >全部禁止转出</input></div><div style=\'maring-left:20px;display: inline-block;width:120px;\'><input Type=\'radio\' id=\'yesall\' name=\'all\' value=\'yesall\'  onc/ick=\'myFunction1()\'>全部允许转出</input></div><div style=\'maring-left:20px;display: inline-block;width:120px;\'><input Type=\'radio\' id= \'choose\' name=\'all\' value=\'choose\' checked >选择授权转出</input></div>")
wb.InsertHTML("form1", "<Table border=1 cellspacing=0 style=\'width:100%;text-align:center;\'><tr style=height:45px;color:red;\'><td style=\'text-align:center;font-size: 15px;strong\'>序号</td><td style=\'text-align:center;font-size: 15px;strong\'>学生姓名</td><td style=\'text-align:center;font-size: 15px;strong\'>禁止转出</td><td style=\'text-align:center;font-size: 15px;strong\'>允许转出</td></tr>")
Dim i As Integer=1
For Each dr As DataRow In dt.DataRows
    If dr("审核锁定")=True
        wb.insertHtml("form1", "<tr style=\'height:45px;\'><td style=font-size:15px\' >" & i & "</td> <td style=font-size:15px\' ><a href=\'sdxsxx.htm?xssfzh=" & dr("身份证件号") & "\'>" & dr("学生姓名") & "</a></td><td><input type=\'radio\' class=\'aa\'  id=\'yes_" & dr("_Identify") & "\' name=\'radio1_" & dr("_Identify") & "\' value=\'yes_" & dr("_Identify") & "\' checked></td><td><input type=\'radio\'class=\'ab\' id= \'no_" & dr("_Identify") & "\' name=\'radio1_" & dr("_Identify") & "\' value=\'no_" & dr("_Identify") & "\' ></td></tr>")
    Else
        wb.insertHtml("form1", "<tr style=\'height:45px;\'><td style=font-size:15px\' >" & i & "</td> <td style=font-size:15px\' ><a href=\'sdxsxx.htm?xssfzh=" & dr("身份证件号") & "\'>" & dr("学生姓名") & "</a></td><td><input type=\'radio\' class=\'aa\'  id=\'yes_" & dr("_Identify") & "\' name=\'radio1_" & dr("_Identify") & "\' value=\'yes_" & dr("_Identify") & "\' ></td><td><input type=\'radio\' class=\'ab\' id= \'no_" & dr("_Identify") & "\' name=\'radio1_" & dr("_Identify") & "\' value=\'no_" & dr("_Identify") & "\'  checked ></td></tr>")
    End If
    i=i+1
Next
wb.insertHtml("form1", "</Table>")
wb.InsertHTML("form1","<button Type=\'submit\'  name=\'submit\'  style=\'position: fixed;left:50%;transform:translate(-50%);bottom:20px;z-index:5;weight:35px;width:35px;background-image:url(../tubiao/ok.png);width: 32px;height: 32px;background-repeat:no-repeat ;background-size:32px 32px; border: 0;background-color: transparent;\'></button>")
wb.AppendHTML("<script>Function myFunction1(){var x = document.querySelectorAll(\'.ab\');  var i;for (i = 0; i < x.length; i++) {x[i].checked = \'true\';}</script>")
e.WriteString(wb.Build)在于
e.Handled=True


还没得行,请帮再看下什么问题
[此贴子已经被作者于2020/11/7 16:59:15编辑过]

--  作者:有点蓝
--  发布时间:2020/11/7 17:00:00
--  
注意大小写,另外js里的括号不成对。建议还是使用js文件吧,起码在使用专业的编辑器编辑js代码的时候可以有出错提示。或者您到js文件编辑代码测试通过后再搬到foxtable里
--  作者:刘林
--  发布时间:2020/11/7 17:05:00
--  
解决了,谢谢