PDA

Click to See Complete Forum and Search --> : lost...dont know which way to turn Please Help!


rigpig
Dec 18th, 2000, 03:19 PM
<!-- #include file = "../include/functions.asp" -->
<%

Dim dbData
Dim rsData
Dim strSQL
Dim rsOptions
Dim CategoryID
Dim VehicleID
Dim numincol
Dim i 'counter
Dim rsCars
Dim selected
Dim VehicleList

selected=false
set dbData = Server.CreateObject("ADODB.Connection")
dbData.Open Application("DSN")

CategoryID = 0
If Request.Form("CategoryID") <> vbNullString Then CategoryID = Request.Form("CategoryID")
If Request.Form("VehicleList") = vbNullString Then
VehicleID = 0
Else
VehicleID = CLng(Request.Form("VehicleList"))
End If

'Connection to Database
Set dbData = Server.CreateObject("ADODB.Connection")
dbData.Open Application("DSN")

'Connection to Recordsets
strSQL = "SELECT ID, Description FROM used_options"
strSQL = strSQL & " Order by Description"
Set rsOptions = Server.CreateObject("ADODB.Recordset")
rsOptions.Open strSQL, dbData, 1, 3

strSQL = "SELECT * From used_cars"
strSQL = strSQL & " INNER JOIN used_category ON used_cars.CategoryID = used_category.ID"
strSQL = strSQL & " INNER JOIN used_car_options ON used_cars.CarID = used_car_options.CarID"
strSQL = strSQL & " INNER JOIN used_options ON used_car_options.OptionID = used_options.ID"
strSQL = strSQL & " WHERE CategoryID = " & CategoryID 'AND used_cars.CarID = " & VehicleID
Set rsData = Server.CreateObject("ADODB.Recordset")
rsData.Open strSQL, dbData, 1, 3
%>
<html>
<head>
<title>Shaganappi Chevrolet Oldsmobile</title>
</head>
<script language="JavaScript">
//Load Models
function LoadMakes()
{
document.frmUsed.submit();
return;
}
</script>

<body bgcolor="#ffffff" alink="#0000ff" vlink="#0000ff" link="#0000ff" marginwidth="0" marginheight="0" leftmargin="0" topmargin="0">
<table border="0" cellpadding="0" cellspacing="0" width="750">
<tr>
<td colspan="2">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td><img SRC="../images/layout/layout1a.gif" WIDTH="235" HEIGHT="83"></td>
<td><img SRC="../images/layout/layout1b.gif" WIDTH="304" HEIGHT="83"></td>
<td><img SRC="../images/layout/layout1c.gif" WIDTH="211" HEIGHT="83"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2" background="../images/layout/layout4.gif" align="right"><img SRC="../images/header/used_admin.gif" WIDTH="525" HEIGHT="55"></td>
</tr>
<tr>
<td height="455" background="../images/layout/layout8.gif" valign="top">
<img SRC="../images/layout/spacer.gif" width="140" height="1">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td colspan="2"><!-- #include file = "../include/admin_menu.htm" --><!-- #include file = "../include/hover_script.htm" --></td>
</tr>
</table>
</td>
<td bgcolor="#ffffff" valign="top" align="center" width="475">
<table border="1" cellpadding="10" cellspacing="0" bordercolor="#000000" bgcolor="#c0c0c0">
<tr>
<td>
<form name="frmUsed" action="newlayout.asp" method="post">
<table cellSpacing="0" cellPadding="0" width="100%" border="1" align="center">
<tr>
<td colSpan="5">
<center>Select the appropriate vehicle type to add to the inventory:</center>
</td>
</tr>
<tr>
<td>
<input type="image" onclick="this.form.CategoryID.value=2;" src="../images/masterimages/truck.gif">
<p>Trucks</p>
</td>
<td>
<input type="image" onclick="this.form.CategoryID.value=1;" src="../images/masterimages/corvette.gif">
<p>Cars</p>
</td>
<td>
<input type="image" onclick="this.form.CategoryID.value=36;" src="../images/masterimages/mvan.gif">
<p>Minivans</p>
</td>
<td>
<input type="image" onclick="this.form.CategoryID.value=31;" src="../images/masterimages/blazer.gif">
<p>SUV's</p>
</td>
<td>
<input type="image" onclick="this.form.CategoryID.value=47;" src="../images/masterimages/van.gif">
<input type="hidden" name="CategoryID" value="<%=CategoryID%>">
<p>Vans</p>
</td>
</tr>
</table>
<br><br>
<center>
<font face="arial" size="5" color="#ff0000"><strong><em>
<%If CategoryID = 2 Then%>
Trucks
<%ElseIf CategoryID = 1 Then%>
Cars
<%ElseIf CategoryID = 36 Then%>
Minivans
<%ElseIf CategoryID = 31 Then%>
Suv's
<%ElseIf CategoryID = 47 Then%>
Vans
<%End If%>
</em></strong></font>
</center>
<table border="1" cellpadding="10" cellspacing="0" bgcolor="c0c0c0" bordercolor="#000000" width="594" align="center">
<tr>
<td colspan="2" align="center">
<select size="10" name="VehicleList" onchange="LoadMakes();">
<option value="0" <%If VehicleID = 0 Then Response.Write "selected" End If%>>--------------------------------------------- New Listing ---------------------------------------------</option>
<%
Dim rsListing

strSQL = "SELECT Year, Make, Model, CarID, CategoryID From used_cars"
strSQL = strSQL & " WHERE CategoryID = " & CategoryID
strSQL = strSQL & " ORDER BY Make"
set rsListing=server.CreateObject("ADODB.Recordset")
rsListing.Open strSQL, dbdata, 1, 3
If NOT (rsListing.BOF AND rsListing.EOF) Then rsListing.MoveFirst
do until rsListing.EOF
%>
<option value="<%=rsListing.Fields("CarID")%>" <%If VehicleID = rsListing.Fields("CarID") Then Response.Write "selected" End If%>><%=rsListing.Fields("Year") & " " & rsListing.Fields("Make") & " " & rsListing.Fields("Model")%></option>
<%
rsListing.MoveNext
loop
rsListing.Close
set rsListing=nothing
%>
</select>
</td>
</tr>
<tr>
<td>
<font face="arial" size="2">Make</font>&nbsp;<input type="text" name="Make" value="<%if selected then Response.Write("Make")%>">

WHY WON'T the value of the make get popultaed into this field? please explain thouroughly please and thanx

</td>

joey o.
Dec 18th, 2000, 04:26 PM
I didn't run your code but I did make an observation that "Make" in the last line (Response.write"Make") was never assigned to or declared as a variable in it's present state. If this is the field name "Make" then you have to tell it that by assigning rsListing.Fields("Make") to a variable before you close rsListing up.

<%make=rsListing.Fields("Make")%>
'Then you can close up the RS
'Then later on:
Response.write"make"
'"make now holds the value of rsListing.Fields("Make")

Hope this helped
JoeyO

rigpig
Dec 19th, 2000, 09:41 AM
Does it matter if the value is coming from the database?

you can view my template at www2.shaganappi.com/pages/newlayout.asp to see what I am trying to do and maybe you will have a good idea of what I am trying to do

Thanx for the help
Clint