I have some problem here with checkbox and logic I think.
table: BusinessType
field: BusinessTypeID, BusinessType
table: Cust_BusinessType
field: Cust_businessTypeID, BusinessTypeID, CompanyID
Let's say when I want to edit company's details, after I search it, and click to see the existing details, the form must have load company profile details. Here got one save_next button, then next page is business type. But, all these business type is in checkbox format. I have problem with this page, mapping the value of checkbox.
My code is below:
<table>
<!--#include file="inc_conn.asp"-->
<%
sql = "select * from businesstype ORDER BY businesstypename"
rs.Open sql, conn, 3, 3
set rs2 = Server.CreateObject("ADODB.recordset")
sql = "select * from cust_businesstype WHERE companyID = " & session("sComID") & " "
rs2.Open sql, conn, 3, 3
DO WHILE NOT rs2.eof
strBusinessTypeID = rs2("businesstypeID")
strBusinessTypeStatus = rs2("businesstypeStatus")
Checked1=""
Checked2=""
if strBusinessTypeID = 1 then
Checked1 = "CHECKED"
end if
DO WHILE NOT rs.eof
response.Write "<tr valign=top><td>" & rs("BusinessTypeName") & "</td>"
response.write "<td><input type=checkbox value=" & rs("BusinessTypeID") & " name='businesstypeID_fr' " & checked1 & "></td></tr>"
rs.MoveNext
LOOP
rs2.MoveNext
LOOP
%>
</table>
I got the 7 checkbox but all was checked which suppose to be only one was checked.