Print Page | Close Window

Load checkbox value

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=7787
Printed Date: 31 March 2026 at 11:22pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Load checkbox value
Posted By: ngaisteve1
Subject: Load checkbox value
Date Posted: 02 December 2003 at 3:01am

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.




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