[thelist] newbie alert! Question about .asp

Salvatore Palmisano spalmisano at usaiss.com
Fri Apr 20 11:15:37 CDT 2001


Checkboxes are either on (CHECKED) or off (nothing).

<INPUT TYPE=CHECKBOX NAME=check1 CHECKED> will produce a checkbox that is
checked by default.

What kind of data is in objRS("Name")?  If its a boolean value (true/false)
you can check its status and write CHECKED as appropriate:
***
If objRS("Name") = 1 Then 'or whatever is stored here
	Response.Write("<INPUT TYPE=CHECKBOX NAME=check1 CHECKED>")
Else
	Response.Write("<INPUT TYPE=CHECKBOX NAME=check1>")
End If
***

Or something similar.
Feel free to post any questions.

--Salvatore Palmisano
Chief Information Officer
International Security Solutions, Inc.
spalmisano at usaiss.com

-----Original Message-----
From: thelist-admin at lists.evolt.org
[mailto:thelist-admin at lists.evolt.org]On Behalf Of Janet Nabring-Stager
Sent: Friday, April 20, 2001 11:53 AM
To: thelist at lists.evolt.org
Subject: [thelist] newbie alert! Question about .asp


I'm attempting to develop and improve my .asp skills at work, so I'm
creating an online cookbook of sorts.
In the following code, the user chooses the recipes they want to view
by checking the checkbox next to the recipe.  As you can probably
tell from the code, I'm attempting to assign the checkbox the value
of the recipe name in the database:
<form name="form1" method="post" action="search_names_results.asp">
  <p>Check on the box next to the recipe name to view a recipe:</p>
  <p>
    <%
Dim strName
strName = "NAME"
While Not objRS.EOF
If objRS("Category") = strCategory Then
	Response.Write "<INPUT TYPE=CHECKBOX VALUE=" & objRS("Name") &
"NAME=" & strName & ">" & objRS("Name") & "<P>"
End If
ObjRS.MoveNext
Wend

ObjRS.Close
Set objRS = Nothing
%>
    <input type="submit" name="Submit" value="Show Recipes">

This is working and I'm very happy!
However, I want the user to be able to click in the checkboxes of the
recipes they want to view and then hit the button and have those
recipes print out.  I'm having troubles!  How do I refer to the Value
of a checkbox?  Is there anything else in this code that is amiss?

<%
Dim objConn, objRS, intCount

Set objConn = Server.CreateObject("ADODB.Connection")
Set objRS = Server.CreateObject("ADODB.Recordset")

objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=d:\Inetpub\wwwroot\connections\InformationServices\CHS_Cookbook_Files
\CHS_Cookbook.mdb;"
objRS.Open "tblRecipe", objConn, adOpenStatic, adLockOptimistic,
adCmdTable

For intCount = 1 to Request.Querystring("NAME").Count
			If objRS("Name") = Request.Form("Value") Then
			Response.Write objRS("Name") & "<BR>" & objRS("Source") & "<P>"
			End If
Next

objRS.Close
Set objRS = Nothing
%>

I apologize for the length of this message and if I'm asking too
specific a question here-please just let me know (nicely, if
possible) if I'm violating any list rules...
TIA-





More information about the thelist mailing list