asp如何从数据库读取单选框
下面是不调用数据库的代码Dimarr_class_tj_Txt,arr_class_tj_Value,i_class_tj,isSel_class_tjarr_class...
下面是不调用数据库的代码
Dim arr_class_tj_Txt, arr_class_tj_Value, i_class_tj, isSel_class_tj
arr_class_tj_Txt = Split("是, 否 ", ", ")
arr_class_tj_Value = Split("1, 0", ", ")
For i_class_tj = 0 To UBound(arr_class_tj_Txt)
isSel_class_tj = ""
If Request.Form("class_tj") = i_class_tj Then isSel_class_tj = " checked"
Response.Write ("<input type='radio' name='class_tj' id='class_tj' value='" & arr_class_tj_Value(i_class_tj) & "' " &
isSel_class_tj & " >" & arr_class_tj_Txt(i_class_tj) & vbcrlf)
Next
数据库单选框字段是class_tj,现在我想用上面的代码改成从数据库读取单选框 展开
Dim arr_class_tj_Txt, arr_class_tj_Value, i_class_tj, isSel_class_tj
arr_class_tj_Txt = Split("是, 否 ", ", ")
arr_class_tj_Value = Split("1, 0", ", ")
For i_class_tj = 0 To UBound(arr_class_tj_Txt)
isSel_class_tj = ""
If Request.Form("class_tj") = i_class_tj Then isSel_class_tj = " checked"
Response.Write ("<input type='radio' name='class_tj' id='class_tj' value='" & arr_class_tj_Value(i_class_tj) & "' " &
isSel_class_tj & " >" & arr_class_tj_Txt(i_class_tj) & vbcrlf)
Next
数据库单选框字段是class_tj,现在我想用上面的代码改成从数据库读取单选框 展开
展开全部
Dim arr_class_tj_Txt, arr_class_tj_Value, i_class_tj, isSel_class_tj
Dim Sql, Rs, ConnStr, tValue
tValue = 0
arr_class_tj_Txt = Split("是, 否 ", ", ")
arr_class_tj_Value = Split("1, 0", ", ")
ConnStr = "这里改成你的数据库连接字符串"
Rs.Open Sql, Conn, 1,1
If Not(Rs.Eof) Then
If IsNumeric(Rs("class_tj")) Then tValue = CLng(Rs("class_tj"))
End If
Rs.Close
Set Rs = Nothing
For i_class_tj = 0 To UBound(arr_class_tj_Txt)
isSel_class_tj = ""
If tValue = i_class_tj Then isSel_class_tj = " checked"
Response.Write ("<input type='radio' name='class_tj' id='class_tj' value='" & arr_class_tj_Value(i_class_tj) & "' " & isSel_class_tj & " >" & arr_class_tj_Txt(i_class_tj) & vbcrlf)
Next
Dim Sql, Rs, ConnStr, tValue
tValue = 0
arr_class_tj_Txt = Split("是, 否 ", ", ")
arr_class_tj_Value = Split("1, 0", ", ")
ConnStr = "这里改成你的数据库连接字符串"
Rs.Open Sql, Conn, 1,1
If Not(Rs.Eof) Then
If IsNumeric(Rs("class_tj")) Then tValue = CLng(Rs("class_tj"))
End If
Rs.Close
Set Rs = Nothing
For i_class_tj = 0 To UBound(arr_class_tj_Txt)
isSel_class_tj = ""
If tValue = i_class_tj Then isSel_class_tj = " checked"
Response.Write ("<input type='radio' name='class_tj' id='class_tj' value='" & arr_class_tj_Value(i_class_tj) & "' " & isSel_class_tj & " >" & arr_class_tj_Txt(i_class_tj) & vbcrlf)
Next
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询