2 tables here:
businesstype: BusinessTypeID, BusinessTypeName
cust_businesstype: Cust_BusinessTypeID, BusinessTypeID, CompanyID
This page load all business type from businesstype table and to edit customer's business type. Thus, this page, there will be some checked checkbox (for business type).
I manage to see that all business type loaded from businesstype but I couldn't see any checked checkbox even though there are records in cust_businesstype.
Anyone can help? Thanks.
Code:
<!--#include file="inc_conn.asp"--> <% set rs2 = Server.CreateObject ("ADODB.recordset")
'It grabs all businesstype of selected company. sql = "select * from cust_businesstype WHERE companyID = " & session("sComID") & " " rs2.Open sql, conn, 3, 3
sql = "select * from businesstype" rs.Open sql, conn, 3, 3 dim CustTypeList, item 'build a list of cust types DO WHILE NOT rs2.eof CustTypeList = CustTypeList & rs2("businesstypeID") & "," rs2.MoveNext Loop 'get rid of last "," CustTypeList = Left(CustTypeList, Len(CustTypeList) - 1) 'turn it into an array CustTypeList = Split(CustTypeList, ",")
DO WHILE NOT rs.eof 'check the list each time through rs to see if the type matches for each item in CustTypeList if rs("businesstypeID") = item then Checked1="Checked" else Checked1="" end if next 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 %>
|
Edited by ngaisteve1