ASP reads the code to read whether the check box is selected from the database
Sometimes, we will use check boxes, that is, multi-select boxes, in web pages. When the user submits input information, we will obtain the content of the check box and then save it to the database. For example, the user Personal information entered. However, when the user submits, it may need to be modified. Then we have to read the form data from the database, which requires that the status previously entered by the user must be displayed. However, when we read from the database whether the check box has been It is indeed difficult to achieve when selected. So today I will teach you how to read out whether the check box is selected from the database through ASP. I hope friends who have other methods can leave a message to share.
The specific code is as follows:
Copy the code code as follows:
<%
document=Split(rs("document"),",") 'The comma here depends on the separator you previously saved to the database
Function check(temp)
check=""
For I=0 To UBound(document)
if temp=document(I) Then
check="checked"
End if
Next
End Function
%>
<input type="checkbox" value="asp" <%=check("asp")%>>
<input type="checkbox" value="java" <%=check("java")%>>
<input type="checkbox" value="php" <%=check("php")%>>