|
 |
asp_databases thread: Checkbox
Message #1 by jhd67@v... on Thu, 5 Dec 2002 16:24:53
|
|
i am trying to compare two Cars once two or three checked you click
submit, and comapre them: here is my first page:
If Request("Checkbox") <> "" Then
Set oRs = cn.Execute("SELECT * FROM CarID WHERE Checkbox = -1")
END IF
'while not oRs.EOF
response.write "<a href='showdetails.asp?CarID=" &server.urlEncode(oRs
("CarID"))& "'>" &"<input name=Checkbox type=checkbox value=(oRs(CarID)
>"&oRs("Year")& "</a>&oRs("Model")& " " &oRs("State")&
Count = Count + 1
oRs.MoveNext
Loop
%>
-------------------------------------------------------------------------
Second page:
<%
Dim Rscomapre
Dim Rscomapre_numRows
Set Rscomapre = Server.CreateObject("ADODB.Recordset")
Rscomapre.ActiveConnection = MM_autofindtwo_STRING
Rscomapre.Source = "SELECT * FROM cars"
Rscomapre.CursorType = 0
Rscomapre.CursorLocation = 2
Rscomapre.LockType = 1
Rscomapre.Open()
Rscomapre_numRows = 0
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
</body>
</html>
<%
Rscomapre.Close()
Set Rscomapre = Nothing
%>
Thank you
Message #2 by imran.saleem@b... on Thu, 5 Dec 2002 16:56:42 -0000
|
|
and the problem is?
-----Original Message-----
From: jhd67@v... [mailto:jhd67@v...]
Sent: Thursday, December 05, 2002 4:25 PM
To: ASP Databases
Subject: [asp_databases] Checkbox
i am trying to compare two Cars once two or three checked you click
submit, and comapre them: here is my first page:
If Request("Checkbox") <> "" Then
Set oRs = cn.Execute("SELECT * FROM CarID WHERE Checkbox = -1")
END IF
'while not oRs.EOF
response.write "<a href='showdetails.asp?CarID=" &server.urlEncode(oRs
("CarID"))& "'>" &"<input name=Checkbox type=checkbox value=(oRs(CarID)
>"&oRs("Year")& "</a>&oRs("Model")& " " &oRs("State")&
Count = Count + 1
oRs.MoveNext
Loop
%>
-------------------------------------------------------------------------
Second page:
<%
Dim Rscomapre
Dim Rscomapre_numRows
Set Rscomapre = Server.CreateObject("ADODB.Recordset")
Rscomapre.ActiveConnection = MM_autofindtwo_STRING
Rscomapre.Source = "SELECT * FROM cars"
Rscomapre.CursorType = 0
Rscomapre.CursorLocation = 2
Rscomapre.LockType = 1
Rscomapre.Open()
Rscomapre_numRows = 0
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
</body>
</html>
<%
Rscomapre.Close()
Set Rscomapre = Nothing
%>
Thank you
Message #3 by jhd67@v... on Fri, 6 Dec 2002 18:13:36
|
|
> 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="VBSCRIPT"%>
<> % Response.Buffer = true %>
> <!-- #include file="configs/adovbs.inc" -->
<> !--#INCLUDE FILE="configs/config.inc" -->
s> et oConn = server.createobject("ADODB.Connection")
o> Conn.Open ConnString
I> f Request("Make") <> "" Then
s> trSQL = "SELECT Make FROM Make WHERE MakeID = " &Request("Make")& ""
s> et rsMake = oConn.execute (strSQL)
M> ake = rsMake("Make")
r> sMake.Close
s> et rsMake = nothing
E> ND IF
> If Request("Model") <> "" Then
s> trSQL = "SELECT Model FROM Model WHERE ModelID = " &Request("Model")& ""
s> et rsModel = oConn.execute (strSQL)
M> odel = rsModel("Model")
r> sModel.Close
s> et rsModel = nothing
E> ND IF
> oConn.close
S> et oConn = nothing
> 'Set how many records per page we want
C> onst NumPerPage = 8
> 'Retrieve what page we are currently on
> If Request.QueryString("CurPage") = "" then
> CurPage = 1 'We're on the first page
E> lse
> CurPage = Request.QueryString("CurPage")
E> nd If
> set oConn = Server.CreateObject("ADODB.Connection")
o> Conn.Open ConnString
> set oRs = server.createobject("ADODB.recordset")
> 'Set the cursor location property
> oRs.CursorLocation = adUseClient
> 'Set the cache size = to the # of records/page
> oRs.CacheSize = NumPerPage
> '*************** Build SQL ************************
T> heYear = Request("Age")
M> ake = Make
M> odel = Model
C> ompanyName = Request("CompanyName")
C> ity = Request("City")
S> tate = Request("State")
A> ge1 = Request("Age1")
A> ge2 = Request("Age2")
P> rice1 = Request("Price1")
P> rice2 = Request("Price2")
> '> search on Price
I> f len(Price1) > 0 then
I> f len(Where_Clause) = 0 then
W> here_Clause = " Where Price BETWEEN "&Price1&" AND "&Price2&""
E> lse
W> here_Clause = 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) = 0 then
W> here_Clause = " Where Year BETWEEN "&Age1&" AND "&Age2&""
E> lse
W> here_Clause = 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) = 0 then
'> Where_Clause = " Where Year=" & TheYear & ""
'> Else
'> Where_Clause = Where_Clause & " and Year=" & TheYear & ""
'> End If
'> End If
> 'search on Make
I> f len(Make) > 0 then
> If len(Where_Clause) = 0 then
> Where_Clause = " WHERE Make = '"& Make &"'"
> Else
> Where_Clause = Where_Clause & " and Make = '"& Make &"'"
> End If
E> nd If
> 'search on Model
I> f len(Model) > 0 then
> If len(Where_Clause) = 0 then
> Where_Clause = " WHERE Model = '"& Model &"'"
> Else
> Where_Clause = Where_Clause & " and Model = '"& Model &"'"
> End If
E> nd If
> 'search on Company Name
I> f len(CompanyName) > 0 then
> If len(Where_Clause) = 0 then
> Where_Clause = " WHERE UserID = "& CompanyName &""
> Else
> Where_Clause = Where_Clause & " and UserID = "& CompanyName &""
> End If
E> nd If
> 'search on City
I> f len(City) > 0 then
> If len(Where_Clause) = 0 then
> Where_Clause = " WHERE City = '"& City &"'"
> Else
> Where_Clause = Where_Clause & " and City = '"& City &"'"
> End If
E> nd If
> 'search on State
I> f len(State) > 0 then
> If len(Where_Clause) = 0 then
> Where_Clause = " WHERE State = '"& State &"'"
> Else
> Where_Clause = Where_Clause & " and State = '"& State &"'"
> End If
E> nd If
> S> trSQL = "SELECT * FROM Cars"
O> rder_Clause = " ORDER BY YEAR DESC"
> ' ****************************************************
s> trsql = strsql & Where_Clause & Order_Clause
'> Response.write "strsql ="&strsql
'> Response.write "<BR>Price1 ="&Price1
'> Response.write "<BR>Price2 ="&Price2
'> Response.write "<BR>Age1 ="&Age1
'> Response.write "<BR>Age2 ="&Age2
o> Rs.Open strSQL, oConn
> > if oRs.recordcount = 0 then
> response.write "<CENTER>"
> response.write "<table WIDTH=""95%"" cellpadding=5 cellspacing=0
b> order=0>"
%> >
<> /head>
> > <p> > <%
> response.write "</TABLE></CENTER>"
e> lse
> oRs.MoveFirst
> oRs.PageSize = NumPerPage
> 'Get the max number of pages
> TotalPages = oRs.PageCount
> 'Set the absolute page
> oRs.AbsolutePage = CurPage
%> >
<> /p>
<> BLOCKQUOTE> > <%
i> f oRs.recordcount = 0 then
> response.write "<table WIDTH=550 cellpadding=5 cellspacing=0 border=0>"
> response.write "<tr><td ALIGN=center bgcolor=000080><font face=verdana
s> ize=2><Font size=2>"
> response.write "Sorry, no cars match your search
c> riteria.</td></TR></TABLE>"
e> lse
%> >
<> /blockquote>
> <p> </p>
<> table Cellpadding="5">
> <> tr> > <td ALIGN=center bgcolor=#FFFFFF COLSPAN=2>
<> form action="test.asp" method="post" name="form1">
> <BLOCKQUOTE>
<> P><BR>
> <table width="50%" CELLPADDING=5>
> <tr> > <td colspan="3" align="center"><font
face="Arial" s> ize="2"><B>The
> following cars match your criteria:</b></font></td>
> </tr>
> </TABLE>
> <P> > <table WIDTH="457" BORDER=0 CELLSPACING=0
CELLPADDING=5
B> ORDERCOLOR=#FFFFFF >
> <tr> > <td WIDTH=97 align="center"
bgcolor="#000080"><font face=Arial
s> ize="2" valign="top" COlor="#FFFFFF"> > Year</font></td>
> <td WIDTH=89 align="center" bgcolor="#000080"><font face=Arial
s> ize="2" valign="top" COlor="#FFFFFF"> > Make</font></td>
> <td WIDTH=122 align="center" bgcolor="#000080"><font
f> ace=Arial size="2" valign="top" COlor="#FFFFFF"> >
Model</font></td>
> <td WIDTH=101 align="center" bgcolor="#000080"><font
f> ace=Arial size="2" valign="top" COlor="#FFFFFF"> >
State/Province</font></td>
> </tr>
> <%
> Do While Not oRs.EOF And Count < oRs.PageSize
> If ColorBG = "#E9E9E9" Then
C> olorBG = "#DDDDDD"
> ELSE
> ColorBG = "#E9E9E9"
E> nd If
> 'while not oRs.EOF
> response.write "<tr BGColor="& ColorBG &"><td WIDTH=100><font
F> ACE=VERDANA SIZE=1 COLOR=000080><b> <CENTER><a href='showdetails.asp?
C> arID=" &server.urlEncode(oRs("CarID"))& "'>" &"<input name=Checkbox
t> ype=checkbox value=(oRs(CarID)>"&oRs("Year")& "</a></b></font></td><td
W> IDTH=100> <CENTER><b> <font FACE=VERDANA SIZE=1 COLOR=000080>" &oRs
(> "Make")& " </font></b></td><td WIDTH=150> <b> <font FACE=VERDANA SIZE=1
C> OLOR=000080><CENTER>" &oRs("Model")& " </font></b></td> <td
W> IDTH=100><CENTER><b> <font FACE=VERDANA SIZE=1 COLOR=000080>" &oRs
(> "State")& "</FONT></B></td></tr>"
> Count = Count + 1
> oRs.MoveNext
L> oop
%> >
> <tr> > <td colspan="4" width="419"> <p
align="center"><a
h> ref="default-slow.asp"><font face="Arial" size="2">new
> search</font></a>
> </p></td>
> </tr>
> <tr> > <td colspan="4" width="419"><hr size="1"
width="67%" noshade
c> olor="#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=BUTTON VALUE=PREV
O> NCLICK=""document.location.href='search-results.asp?
A>
ge1="&Age1&"&Age2="&Age2&"&Price1="&Price1&"&Price2="&Price2&"&Make="&Make
&> "&Model=" & Model & "&CompanyName=" & CompanyName & "&City=" & City
&> "&State=" & State & "&curpage=" & curpage - 1 & "';"">")
> End If
> If CInt(CurPage) <> CInt(TotalPages) then
> 'We are not at the end, show a next button
> Response.Write("<INPUT TYPE=BUTTON VALUE=NEXT
O> NCLICK=""document.location.href='search-results.asp?
A>
ge1="&Age1&"&Age2="&Age2&"&Price1="&Price1&"&Price2="&Price2&"&Make="&Make
&> "&Model=" & Model & "&CompanyName=" & CompanyName & "&City=" & City
&> "&State=" & State & "&curpage=" & curpage + 1 & "';"">")
> End If
> End If
E> nd If
%> >
> </center></td>
> </tr>
> </table>
> <div align="center"> > <!-- END PAGE DISPLAY -->
> </div>
> <input type="submit" name="Submit" value="Submit">
> </blockquote>
> </form>
> <Font size=2 face="Arial" COLOR="FFFFFF"> </font></td>
<> /TR>
> <%
o> Rs.Close
s> et oRs = nothing
o> Conn.Close
S> et oConn = nothing
%> >
> > Second result page:
> <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<> !--#include file="../Connections/autofindtwo.asp" -->
<> %
D> im Rscomapre
D> im Rscomapre_numRows
> Set Rscomapre = Server.CreateObject("ADODB.Recordset")
R> scomapre.ActiveConnection = MM_autofindtwo_STRING
R> scomapre.Source = "SELECT * FROM cars"
R> scomapre.CursorType = 0
R> scomapre.CursorLocation = 2
R> scomapre.LockType = 1
R> scomapre.Open()
> Rscomapre_numRows = 0
%> >
<> html>
<> head>
<> title>Untitled Document</title>
<> meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<> /head>
> <body>
<> %=(Rscomapre.Fields.Item("Make").Value)%> <%=(Rscomapre.Fields.Item
(> "Model").Value)%> <> /body>
<> /html>
<> %
R> scomapre.Close()
S> et Rscomapre = Nothing
%> >
|
|
 |