0
votes

How can I make a radio button checked based on the database value in ASP Classic using a MS Access database? For example, when I insert into database using radio button like Gender, if I selected Male how can I retrieve the the Male checked in radio button?

This is the code I used:

Gender:
<label><input type="radio" name="gend" value="Male" id="male">Male</label>
<label><input type="radio" name="gend" value="Female" id="female">Female</label>

I also use this in retrieving values from database:

<% =rs.fields("emp_gender") %>

Please help me to achieve this. Thanks in advance.

1

1 Answers

1
votes
<%
public function iif(i, j, k)
    if i then iif = j else iif = k
end function

%>
<label><input type="radio" name="gend" value="Male" id="male" <%=iif(rs.fields("emp_gender")="Male", "checked", "")%>>Male</label>
<label><input type="radio" name="gend" value="Female" id="female" <%=iif(rs.fields("emp_gender")="Female", "checked", "")%>>Female</label>