Print Page | Close Window

Can’t see checked checkbox

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=7866
Printed Date: 01 April 2026 at 1:00am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Can’t see checked checkbox
Posted By: ngaisteve1
Subject: Can’t see checked checkbox
Date Posted: 04 December 2003 at 11:15pm

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
%> 




Replies:
Posted By: pmormr
Date Posted: 05 December 2003 at 1:10pm

Quote 'turn it into an array

  1. why are you turning that into an array
  2. please don't make your posts so wide...
  3. work on your whitespace!

your problem is when you set the checked unchecked variable... you go through setting your variable several times... that's one suspicion and another suspicion is between the first and the second do while loop you never reset the record pointer to the first record so you start at the end when you do your for loop

hope i helped



-------------
Paul A Morgan

http://www.pmorganphoto.com/" rel="nofollow - http://www.pmorganphoto.com/


Posted By: ngaisteve1
Date Posted: 05 December 2003 at 7:11pm

Yeah, you are right, shouldn't have to turn it into an array.

Ok, I'll align my code next time.




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net