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
前台用EL表达式来接数据。<c:if test=${sex=='0'}>
<script type="javascript/text">
var radio=document.getElementByid("男的id");
radio.checked="checked"
</script>
</c:if>
<c:if test=${sex=='1'}>
<script type="javascript/text">
var radio=document.getElementByid("女的id");
radio.checked="checked"
</script>
</c:if>
当然还有别的方法,这就是其中之一的方法。 这条语句是在循环之中你知道吧。详细的不说了,你应该不是小白吧。
从后台读出来标记String sex=读出来的数据(男或女),在jsp里的select里做个sex的判断,如果读出的值是sex="男"就显示男,不是男的就显示是女的(除非你还有空的选项)欢迎分享,转载请注明来源:内存溢出
评论列表(0条)