循环中预填充复选框 [英] pre-populate checkbox in a loop
本文介绍了循环中预填充复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试预填充Do..Loop
中的复选框. QueryString
中的值与数据库中的值匹配.但是在这种情况下,所有QueryString
值都将被选中.
I am trying to pre-populate the checkboxes in a Do..Loop
. The values from the QueryString
are matched with the value from database. But in this case, all check boxes are checked irrespective of any QueryString
value.
VBscript代码如下:
The VBscript code is given below:
<%
Do While Not RS.EOF
Designchk = Request.QueryString("Designer")
Designchk2 = RS("Brand")
If InStr(Designchk, DesignchkP2) Then
chkd = "checked"
End If
ListL = ListL & vbCrLf & "<li><label class='contR'>" & Designchk2 & _
"<input type='checkbox' " & chkd & " name='Designer' value=" & _
Designchk2 & "></label></li>"
RS.MoveNext
Loop
%>
推荐答案
您永远不会在任何地方重设chkd
,因此一旦检查,它仍会保持这种状态.
You never reset chkd
anywhere, so once checked it remains that way.
更改此:
If InStr(Designchk, DesignchkP2) Then
chkd = "checked"
End If
对此:
chkd = ""
If InStr(Designchk, DesignchkP2) Then
chkd = "checked"
End If
问题将消失.
这篇关于循环中预填充复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文