[thelist] newbie alert! Question about .asp

Anthony Baratta Anthony at Baratta.com
Fri Apr 20 11:53:28 CDT 2001


At 09:31 AM 4/20/2001, you wrote:
>Thanks so much for the response!
>Actually, 'Name' is the Name of the recipe (I know this is truly
>trivial, but bear with me...)
>I need to check to see if the checkbox is checked and if so, match
>the Name (or what I hope is the Value) of the checkbox to the Name in
>the database and print out the recipe...
>So I'm back to two questions:  how do I determine whether or not a
>checkbox is checked and then how do I determine the value of a
>checkbox from within JavaScript?

Janet...

Only those check boxes that are check are passed to the server when a form 
is submitted. Therefore a check box value will exist only for those check 
boxes check. (Clear as mud?)

I was review your code:

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

I think you are mixing your metaphors here. If you are submitting your 
form, you either POST or GET your form. Therefore using Request.Querystring 
along with Request.Form won't work since only one or the other will be 
there, unless you are specifically passing a query sting within the ACTION 
of the form.

         e.g. <form action="./script.asp?ID=1" method="POST">

I also don't see a SQL statement that collects the data from the tables.

Here's how I approach the problem....(this is off the top of my head, 
expect errors)

'' dictionary object for storing selected Recipes
Set dictRecipeInfo = Server.CreateObject("Scripting.Dictionary")

'' ADO DB Connection Object
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=d:\Inetpub\wwwroot\connections\InformationServices\CHS_Cookbook_Files\CHS_Cookbook.mdb;"

'' SQL Query
strQuery = "Select Name, Recipe_Text from Recipes"

'' Opening Up Record Set
Set objRS = objConn.Execute(strQuery)
objRS.MoveFirst

'' Iterating through Record Set and comparing to Form Data
while not objRS
     for each fld in Request.Form
         '' If match, store in Dictionary Object
         if (Trim(objRS("Name")) = fld.Name) then
              dictRecipeInfo(fld.Name) = fld.Value
         end if
     next
     objRS.MoveNext
wend
'' Cleaning up DB Objects
Set objRS = Nothing
Set objConn = Nothing

'' Printing Recipes matched to Browser
for each fld in dictRecipeInfo
     Response.Write dictRecipeInfo(fld)
next

'' Cleaning up dictionary object
Set dictRecipeInfo = Nothing
---
Anthony Baratta
President
Keyboard Jockeys





More information about the thelist mailing list