Database 比较数据并创建复选框
请帮忙。以下代码运行良好,但会创建重复的值。我如何解决这个问题。我想我把分割函数放错地方了Database 比较数据并创建复选框,database,for-loop,checkbox,split,asp-classic,Database,For Loop,Checkbox,Split,Asp Classic,请帮忙。以下代码运行良好,但会创建重复的值。我如何解决这个问题。我想我把分割函数放错地方了 customer_choice=request.QueryString("customer_choice") strSQL="Select distinct computer_name from item" rs.Open strSQL, adoCon,1,1 rs.MoveFirst while not rs.EOF abc=split(customer_choice,",")
customer_choice=request.QueryString("customer_choice")
strSQL="Select distinct computer_name from item"
rs.Open strSQL, adoCon,1,1
rs.MoveFirst
while not rs.EOF
abc=split(customer_choice,",")
for i=0 to UBound(abc)
if rs("computer_name")=abc(i) then
response.Write("<input type='checkbox' id='c1' name='c1' value='" & rs("computer_name") & "' checked>" & rs("computer_name") & "</br></input>")
else
response.Write("<input type='checkbox' id='c1' name='c1' value='" & rs("computer_name") & "'>" & rs("computer_name") & "</br></input>")
end if
next
rs.MoveNext
wend
rs.Close
customer\u choice=request.QueryString(“customer\u choice”)
strSQL=“从项目中选择不同的计算机名称”
rs.开放式strSQL,adoCon,1,1
先走一步
而不是卢比
abc=拆分(客户选择“,”)
对于i=0至UBound(abc)
如果rs(“计算机名称”)=abc(i),则
回答。写(“&rs(“计算机名称”)和“”)
其他的
回答。写(“&rs(“计算机名称”)和“”)
如果结束
下一个
下一个
温德
rs.Close
您需要检查是否找到了结果
尝试:
customer\u choice=request.QueryString(“customer\u choice”)
Dim用户选择基金
strSQL=“从项目中选择不同的计算机名称”
rs.开放式strSQL,adoCon,1,1
先走一步
而不是卢比
abc=拆分(客户选择“,”)
userChoiceFound=false
对于i=0至UBound(abc)
如果rs(“计算机名称”)=abc(i),则
userChoiceFound=true
回答。写(“&rs(“计算机名称”)&”)
退出
如果结束
下一个
如果不是UserChoiceFund,则
回答。写(“&rs(“计算机名称”)和“”)
如果结束
下一个
温德
rs.Close
customer_choice=request.QueryString("customer_choice")
Dim userChoiceFound
strSQL="Select distinct computer_name from item"
rs.Open strSQL, adoCon,1,1
rs.MoveFirst
while not rs.EOF
abc=split(customer_choice,",")
userChoiceFound = false
for i=0 to UBound(abc)
if rs("computer_name")=abc(i) then
userChoiceFound = true
response.Write("<input type='checkbox' id='c1' name='c1' value='" & rs("district") & "' checked>" & rs("computer_name") & "</input>")
exit for
end if
next
if not userChoiceFound then
response.Write("<input type='checkbox' id='c1' name='c1' value='" & rs("computer_name") & "'>" & rs("computer_name") & "</br></input>")
end if
rs.MoveNext
wend
rs.Close