Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Can’t see checked checkbox
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Can’t see checked checkbox

 Post Reply Post Reply
Author
ngaisteve1 View Drop Down
Groupie
Groupie
Avatar

Joined: 26 December 2002
Location: Malaysia
Status: Offline
Points: 169
Post Options Post Options   Thanks (0) Thanks(0)   Quote ngaisteve1 Quote  Post ReplyReply Direct Link To This Post Topic: Can’t see checked checkbox
    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
%> 



Edited by ngaisteve1
Back to Top
pmormr View Drop Down
Senior Member
Senior Member


Joined: 06 January 2003
Location: United States
Status: Offline
Points: 1479
Post Options Post Options   Thanks (0) Thanks(0)   Quote pmormr Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
ngaisteve1 View Drop Down
Groupie
Groupie
Avatar

Joined: 26 December 2002
Location: Malaysia
Status: Offline
Points: 169
Post Options Post Options   Thanks (0) Thanks(0)   Quote ngaisteve1 Quote  Post ReplyReply Direct Link To This Post 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.

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.