Chris,
Have you given the checkboxes a different name/id for each check box?
Rod
-----Original Message-----
From: Chris Moritz [mailto:cmoritz@a...]
Sent: Friday, 6 December 2002 11:55 PM
To: HTML Code Clinic
Subject: [html_code_clinic] Re: checkbox
I'm thinking you might want to fire this query off to the ASP forum -
they
should be able to give you better advice.
> I am building a site for a car dealer, I did get almost everything
w> orking. But he wants to add on the result page an option "checkbox"
where
b> uyer
c> an select two three ... car and compare them.
I> did add field on my database called check box and set it up to
yes/no.
a> nd add check box on the result page which will have the value of
"carid"
a> nd when I select two check boxes and click submit I only get the
first ID
o> n the second result page:
H> ere is the First result page:
> <%@LANGUAGE=3D"VBSCRIPT"%>
<> % Response.Buffer =3D true %>
> <!-- #include file=3D"configs/adovbs.inc" -->
<> !--#INCLUDE FILE=3D"configs/config.inc" -->
s> et oConn =3D server.createobject("ADODB.Connection")
o> Conn.Open ConnString
I> f Request("Make") <> "" Then
s> trSQL =3D "SELECT Make FROM Make WHERE MakeID =3D " &Request("Make")&
""
s> et rsMake =3D oConn.execute (strSQL)
M> ake =3D rsMake("Make")
r> sMake.Close
s> et rsMake =3D nothing
E> ND IF
> If Request("Model") <> "" Then
s> trSQL =3D "SELECT Model FROM Model WHERE ModelID =3D "
&Request("Model")& ""
s> et rsModel =3D oConn.execute (strSQL)
M> odel =3D rsModel("Model")
r> sModel.Close
s> et rsModel =3D nothing
E> ND IF
> oConn.close
S> et oConn =3D nothing
> 'Set how many records per page we want
C> onst NumPerPage =3D 8
> 'Retrieve what page we are currently on
> If Request.QueryString("CurPage") =3D "" then
> CurPage =3D 1 'We're on the first page
E> lse
> CurPage =3D Request.QueryString("CurPage")
E> nd If
> set oConn =3D Server.CreateObject("ADODB.Connection")
o> Conn.Open ConnString
> set oRs =3D server.createobject("ADODB.recordset")
> 'Set the cursor location property
> oRs.CursorLocation =3D adUseClient
> 'Set the cache size =3D to the # of records/page
> oRs.CacheSize =3D NumPerPage
> '*************** Build SQL ************************
T> heYear =3D Request("Age")
M> ake =3D Make
M> odel =3D Model
C> ompanyName =3D Request("CompanyName")
C> ity =3D Request("City")
S> tate =3D Request("State")
A> ge1 =3D Request("Age1")
A> ge2 =3D Request("Age2")
P> rice1 =3D Request("Price1")
P> rice2 =3D Request("Price2")
> '> search on Price
I> f len(Price1) > 0 then
I> f len(Where_Clause) =3D 0 then
W> here_Clause =3D " Where Price BETWEEN "&Price1&" AND "&Price2&""
E> lse
W> here_Clause =3D Where_Clause & " and Price BETWEEN "&Price1&" A> ND
"&Price2&""
E> nd If
E> nd If
'> End IF
> '> search on Year
I> f len(Age1) > 0 then
I> f len(Age2) > 0 then
I> f len(Where_Clause) =3D 0 then
W> here_Clause =3D " Where Year BETWEEN "&Age1&" AND "&Age2&""
E> lse
W> here_Clause =3D Where_Clause & " and Year BETWEEN "&Age1&" AND
"&Age2&""
E> nd If
E> nd If
E> nd IF
> 'search on Year
'> If len(TheYear) > 0 then
'> If len(Where_Clause) =3D 0 then
'> Where_Clause =3D " Where Year=3D" & TheYear & ""
'> Else
'> Where_Clause =3D Where_Clause & " and Year=3D" & TheYear & ""
'> End If
'> End If
> 'search on Make
I> f len(Make) > 0 then
> If len(Where_Clause) =3D 0 then
> Where_Clause =3D " WHERE Make =3D '"& Make &"'"
> Else
> Where_Clause =3D Where_Clause & " and Make =3D '"& Make &"'"
> End If
E> nd If
> 'search on Model
I> f len(Model) > 0 then
> If len(Where_Clause) =3D 0 then
> Where_Clause =3D " WHERE Model =3D '"& Model &"'"
> Else
> Where_Clause =3D Where_Clause & " and Model =3D '"& Model &"'"
> End If
E> nd If
> 'search on Company Name
I> f len(CompanyName) > 0 then
> If len(Where_Clause) =3D 0 then
> Where_Clause =3D " WHERE UserID =3D "& CompanyName &""
> Else
> Where_Clause =3D Where_Clause & " and UserID =3D "& CompanyName &""
> End If
E> nd If
> 'search on City
I> f len(City) > 0 then
> If len(Where_Clause) =3D 0 then
> Where_Clause =3D " WHERE City =3D '"& City &"'"
> Else
> Where_Clause =3D Where_Clause & " and City =3D '"& City &"'"
> End If
E> nd If
> 'search on State
I> f len(State) > 0 then
> If len(Where_Clause) =3D 0 then
> Where_Clause =3D " WHERE State =3D '"& State &"'"
> Else
> Where_Clause =3D Where_Clause & " and State =3D '"& State &"'"
> End If
E> nd If
> S> trSQL =3D "SELECT * FROM Cars"
O> rder_Clause =3D " ORDER BY YEAR DESC"
> ' ****************************************************
s> trsql =3D strsql & Where_Clause & Order_Clause
'> Response.write "strsql =3D"&strsql
'> Response.write "<BR>Price1 =3D"&Price1
'> Response.write "<BR>Price2 =3D"&Price2
'> Response.write "<BR>Age1 =3D"&Age1
'> Response.write "<BR>Age2 =3D"&Age2
o> Rs.Open strSQL, oConn
> > if oRs.recordcount =3D 0 then
> response.write "<CENTER>"
> response.write "<table WIDTH=3D""95%"" cellpadding=3D5
cellspacing=3D0
b> order=3D0>"
%> >
<> /head>
> > <p> > <%
> response.write "</TABLE></CENTER>"
e> lse
> oRs.MoveFirst
> oRs.PageSize =3D NumPerPage
> 'Get the max number of pages
> TotalPages =3D oRs.PageCount
> 'Set the absolute page
> oRs.AbsolutePage =3D CurPage
%> >
<> /p>
<> BLOCKQUOTE> > <%
i> f oRs.recordcount =3D 0 then
> response.write "<table WIDTH=3D550 cellpadding=3D5 cellspacing=3D0
border=3D0>"
> response.write "<tr><td ALIGN=3Dcenter bgcolor=3D000080><font
face=3Dverdana
s> ize=3D2><Font size=3D2>"
> response.write "Sorry, no cars match your search
c> riteria.</td></TR></TABLE>"
e> lse
%> >
<> /blockquote>
> <p> </p>
<> table Cellpadding=3D"5">
> <> tr> > <td ALIGN=3Dcenter bgcolor=3D#FFFFFF COLSPAN=3D2>
<> form action=3D"test.asp" method=3D"post" name=3D"form1">
> <BLOCKQUOTE>
<> P><BR>
> <table width=3D"50%" CELLPADDING=3D5>
> <tr> > <td colspan=3D"3" align=3D"center"><font
face=3D"Arial" s> ize=3D"2"><B>The
> following cars match your criteria:</b></font></td>
> </tr>
> </TABLE>
> <P> > <table WIDTH=3D"457" BORDER=3D0 CELLSPACING=3D0
CELLPADDING=3D5
B> ORDERCOLOR=3D#FFFFFF >
> <tr> > <td WIDTH=3D97 align=3D"center"
bgcolor=3D"#000080"><font face=3DArial
s> ize=3D"2" valign=3D"top" COlor=3D"#FFFFFF"> >
Year</font></td>
> <td WIDTH=3D89 align=3D"center" bgcolor=3D"#000080"><font
face=3DArial
s> ize=3D"2" valign=3D"top" COlor=3D"#FFFFFF"> >
Make</font></td>
> <td WIDTH=3D122 align=3D"center" bgcolor=3D"#000080"><font
f> ace=3DArial size=3D"2" valign=3D"top" COlor=3D"#FFFFFF"> >
Model</font></td>
> <td WIDTH=3D101 align=3D"center" bgcolor=3D"#000080"><font
f> ace=3DArial size=3D"2" valign=3D"top" COlor=3D"#FFFFFF"> >
State/Province</font></td>
> </tr>
> <%
> Do While Not oRs.EOF And Count < oRs.PageSize
> If ColorBG =3D "#E9E9E9" Then
C> olorBG =3D "#DDDDDD"
> ELSE
> ColorBG =3D "#E9E9E9"
E> nd If
> 'while not oRs.EOF
> response.write "<tr BGColor=3D"& ColorBG &"><td WIDTH=3D100><font
F> ACE=3DVERDANA SIZE=3D1 COLOR=3D000080><b> <CENTER><a
href=3D'showdetails.asp?
C> arID=3D" &server.urlEncode(oRs("CarID"))& "'>" &"<input
name=3DCheckbox
t> ype=3Dcheckbox value=3D(oRs(CarID)>"&oRs("Year")&
"</a></b></font></td><td
W> IDTH=3D100> <CENTER><b> <font FACE=3DVERDANA SIZE=3D1
COLOR=3D000080>" &oRs
(> "Make")& " </font></b></td><td WIDTH=3D150> <b> <font FACE=3DVERDANA
SIZE=3D1
C> OLOR=3D000080><CENTER>" &oRs("Model")& " </font></b></td> <td
W> IDTH=3D100><CENTER><b> <font FACE=3DVERDANA SIZE=3D1 COLOR=3D000080>"
&oRs
(> "State")& "</FONT></B></td></tr>"
> Count =3D Count + 1
> oRs.MoveNext
L> oop
%> >
> <tr> > <td colspan=3D"4" width=3D"419"> <p
align=3D"center"><a
h> ref=3D"default-slow.asp"><font face=3D"Arial" size=3D"2">new
> search</font></a>
> </p></td>
> </tr>
> <tr> > <td colspan=3D"4" width=3D"419"><hr
size=3D"1"
width=3D"67%" noshade
c> olor=3D"#336699"> > <CENTER>
> > <%
> 'Print out the current page # / total pages
> Response.Write("<B>Page " & CurPage & " of " & TotalPages &
"<P></B>")
> 'Display Next / Prev buttons
> if CurPage > 1 then
> 'We are not at the beginning, show the prev button
> Response.Write("<INPUT TYPE=3DBUTTON VALUE=3DPREV
O> NCLICK=3D""document.location.href=3D'search-results.asp?
A>
ge1=3D"&Age1&"&Age2=3D"&Age2&"&Price1=3D"&Price1&"&Price2=3D"&Price2&"&Ma
ke=3D"&Make
&> "&Model=3D" & Model & "&CompanyName=3D" & CompanyName & "&City=3D" &
City
&> "&State=3D" & State & "&curpage=3D" & curpage - 1 & "';"">")
> End If
> If CInt(CurPage) <> CInt(TotalPages) then
> 'We are not at the end, show a next button
> Response.Write("<INPUT TYPE=3DBUTTON VALUE=3DNEXT
O> NCLICK=3D""document.location.href=3D'search-results.asp?
A>
ge1=3D"&Age1&"&Age2=3D"&Age2&"&Price1=3D"&Price1&"&Price2=3D"&Price2&"&Ma
ke=3D"&Make
&> "&Model=3D" & Model & "&CompanyName=3D" & CompanyName & "&City=3D" &
City
&> "&State=3D" & State & "&curpage=3D" & curpage + 1 & "';"">")
> End If
> End If
E> nd If
%> >
> </center></td>
> </tr>
> </table>
> <div align=3D"center"> > <!-- END PAGE DISPLAY -->
> </div>
> <input type=3D"submit" name=3D"Submit" value=3D"Submit">
> </blockquote>
> </form>
> <Font size=3D2 face=3D"Arial" COLOR=3D"FFFFFF"> </font></td>
<> /TR>
> <%
o> Rs.Close
s> et oRs =3D nothing
o> Conn.Close
S> et oConn =3D nothing
%> >
> > Second result page:
> <%@LANGUAGE=3D"VBSCRIPT" CODEPAGE=3D"1252"%>
<> !--#include file=3D"../Connections/autofindtwo.asp" -->
<> %
D> im Rscomapre
D> im Rscomapre_numRows
> Set Rscomapre =3D Server.CreateObject("ADODB.Recordset")
R> scomapre.ActiveConnection =3D MM_autofindtwo_STRING
R> scomapre.Source =3D "SELECT * FROM cars"
R> scomapre.CursorType =3D 0
R> scomapre.CursorLocation =3D 2
R> scomapre.LockType =3D 1
R> scomapre.Open()
> Rscomapre_numRows =3D 0
%> >
<> html>
<> head>
<> title>Untitled Document</title>
<> meta http-equiv=3D"Content-Type" content=3D"text/html;
charset=3Diso-8859-1">
<> /head>
> <body>
<> %=3D(Rscomapre.Fields.Item("Make").Value)%>
<%=3D(Rscomapre.Fields.Item
(> "Model").Value)%> <> /body>
<> /html>
<> %
R> scomapre.Close()
S> et Rscomapre =3D Nothing
%> >
I> will appreciate any help or advice
> >