navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

Microsoft MVP

 

Multiple Drop Down - All Value Option

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> Multiple Drop Down - All Value Option
Page: [1]
 
4ank

 

Posts: 11
Joined: 2/11/2004
Status: offline

 
Multiple Drop Down - All Value Option - 2/16/2004 21:51:45   
Hi all.

I read an older post about multiple drop down menu's and borrowed some code from it, but I cannot seem to get the all value option working. I am making an inventory site for a very small used car dealership and I want to be able to search by make and model, or just make, or all inventory (any make option, any model option).

Here is my code currently:

quote:

<form method="POST" name="Form1" action="Page1.asp">

<p><nobr><!--#include file="_fpclass/fpdblib.inc"-->
<%
fp_sQry="SELECT DISTINCT Make FROM Results"
fp_sDefault=""
fp_sNoRecords="No records returned."
fp_sDataConn="inventory"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=False
fp_fMenuFormat=True
fp_sMenuChoice="Make"
fp_sMenuValue="Make"
fp_iDisplayCols=1
fp_fCustomQuery=False
BOTID=0
fp_iRegion=BOTID
%>

<select NAME="Make" SIZE="1" ONCHANGE=Form1.submit()>
<option><%=Request.Form("Make")%></option>
<!--#include file="_fpclass/fpdbrgn1.inc"-->
<option><%=FP_FieldHTML(fp_rs,"Make")%></option>
<!--#include file="_fpclass/fpdbrgn2.inc"-->
</select>
</nobr></p>
</form>



<form method="POST" name="Form2" action="Page2.asp">

<p><nobr><!--#include file="_fpclass/fpdblib.inc"-->
<%
fp_sQry="SELECT DISTINCT Model FROM Results WHERE Make = '::Make::'"
fp_sDefault=""
fp_sNoRecords="No records returned."
fp_sDataConn="inventory"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=False
fp_fMenuFormat=True
fp_sMenuChoice="Model"
fp_sMenuValue="Model"
fp_iDisplayCols=1
fp_fCustomQuery=False
BOTID=0
fp_iRegion=BOTID
%>

<select NAME="Model" SIZE="1">
<option><%=Request.Form("Model")%></option>
<!--#include file="_fpclass/fpdbrgn1.inc"-->
<option><%=FP_FieldHTML(fp_rs,"Model")%></option>
<!--#include file="_fpclass/fpdbrgn2.inc"-->
</select>
</nobr></p>
<input type="hidden" name="Make" value="<% = Request.Form("Make") %>">
<p align="center">
<input type=submit value=search ONCLICK=Form2.submit()> </p>
<p align="center"> </p>
</form>


Any help cleaning this up and getting the all value option for each of the forms to work appreciated.

Thanks

Frank
Spooky

 

Posts: 26599
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Multiple Drop Down - All Value Option - 2/16/2004 22:46:10   
Add an "all model" option

<select NAME="Make" SIZE="1" ONCHANGE=Form1.submit()>
<option><%=Request.Form("Make")%></option>

<option value='%'>All models</option>

and modify your SQL slightly:

<p><nobr><!--#include file="_fpclass/fpdblib.inc"-->
<%
fp_sQry="SELECT DISTINCT Model FROM Results WHERE Make LIKE '%::Make::%'"


_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to 4ank)
4ank

 

Posts: 11
Joined: 2/11/2004
Status: offline

 
RE: Multiple Drop Down - All Value Option - 2/16/2004 23:46:11   
Thanks Spooky. From what I read before and now, you seem very helpful and knowledgeable.

I tried what you said, but it does not work for me. I see what it does, allowing the user to choose any model they want. However, what I want is for them to be required to choose a make (or leave the default any make assigned) before they choose a model (or leave the default any model assigned).

For some reason when I assign the value % it does not work for me. I return no records unless both the make and model are chosen.

What are my other options to cure this?

Thanks again

(in reply to Spooky)
BeTheBall

 

Posts: 6356
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: Multiple Drop Down - All Value Option - 2/17/2004 10:21:23   
See if the changes below get you where you need. If not, what is the SQL on Page2.asp.

<form method="POST" name="Form1" action="Page1.asp">

<p><nobr><!--#include file="_fpclass/fpdblib.inc"-->
<%
fp_sQry="SELECT DISTINCT Make FROM Results"
fp_sDefault=""
fp_sNoRecords="No records returned."
fp_sDataConn="inventory"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=False
fp_fMenuFormat=True
fp_sMenuChoice="Make"
fp_sMenuValue="Make"
fp_iDisplayCols=1
fp_fCustomQuery=False
BOTID=0
fp_iRegion=BOTID
%>

<select NAME="Make" SIZE="1" ONCHANGE=Form1.submit()>
<option value="%">All</option>
<option><%=Request.Form("Make")%></option>
<!--#include file="_fpclass/fpdbrgn1.inc"-->
<option><%=FP_FieldHTML(fp_rs,"Make")%></option>
<!--#include file="_fpclass/fpdbrgn2.inc"-->
</select>
</nobr></p>
</form>

<form method="POST" name="Form2" action="Page2.asp">

<p><nobr><!--#include file="_fpclass/fpdblib.inc"-->
<%
fp_sQry="SELECT DISTINCT Model FROM Results WHERE Make LIKE '%::Make::%'"
fp_sDefault=""
fp_sNoRecords="No records returned."
fp_sDataConn="inventory"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=False
fp_fMenuFormat=True
fp_sMenuChoice="Model"
fp_sMenuValue="Model"
fp_iDisplayCols=1
fp_fCustomQuery=False
BOTID=0
fp_iRegion=BOTID
%>

<select NAME="Model" SIZE="1">
<option value="%" <%If Request.Form("Make")="%" Then Response.write ("selected") End If%>>All</option>
<option><%=Request.Form("Model")%></option>
<!--#include file="_fpclass/fpdbrgn1.inc"-->
<option><%=FP_FieldHTML(fp_rs,"Model")%></option>
<!--#include file="_fpclass/fpdbrgn2.inc"-->
</select>
</nobr></p>
<input type="hidden" name="Make" value="<% = Request.Form("Make") %>">
<p align="center">
<input type=submit value=search ONCLICK=Form2.submit()> </p>
<p align="center"> </p>
</form>

< Message edited by betheball -- 2/17/2004 8:22:52 >


_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to 4ank)
4ank

 

Posts: 11
Joined: 2/11/2004
Status: offline

 
RE: Multiple Drop Down - All Value Option - 2/17/2004 12:56:44   
Thanks for the help the both of you.

I quick tried the above suggestion and it did not do what I wanted it to do. It returned no records when I selected all for both the make and model. Also, when i try to chose a make, it quick changes back to all - is there a way to get around that and still being able to use the all values.

I am thinking like you said I need to change something in the page2.asp. Here it is. I will mess around more with it later. Again, many thanks.

From Page2.asp
quote:

<%
fp_sQry="SELECT * FROM Results WHERE (Make = '::Make::' AND Model = '::Model::')"
fp_sDefault="Make=&Model="
fp_sNoRecords="<tr><td colspan=4 align=left width=""100%"">No records returned.</td></tr>"
fp_sDataConn="inventory"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice=""
fp_sMenuValue=""
fp_iDisplayCols=4
fp_fCustomQuery=False
BOTID=0
fp_iRegion=BOTID
%>

(in reply to BeTheBall)
BeTheBall

 

Posts: 6356
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: Multiple Drop Down - All Value Option - 2/17/2004 13:40:22   
Your SQL on Page 2 needs to be changed to:

fp_sQry="SELECT * FROM Results WHERE (Make LIKE '%::Make::%' AND Model LIKE '%::Model::%')"

Now, you need to apply the Spooky Diet to your page before changing the SQL, otherwise, FP will revert back to the previous code. Here is a link to the Diet: http://www.outfront.net/spooky/adv_drw_diet.htm

As for the other issue, change this:

<option><%=Request.Form("Make")%></option>

To:

<option value=<%=Request.Form("Make")%><%If Request.Form("Make")=FP_Field(fp_rs,"Model") THEN Response.write("selected") End If%>><%=Request.Form("Make")%></option>

I think (untested).

_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to 4ank)
4ank

 

Posts: 11
Joined: 2/11/2004
Status: offline

 
RE: Multiple Drop Down - All Value Option - 2/17/2004 20:28:27   
I think what you gave me will work. however, right now once I select a Make, it jumps right back to the all option, therefore not allowing me to choose a model and not query my search by just make. how do I get the make to stay selected.

Oh, and the spooky diet = excellent!

Thanks

(in reply to BeTheBall)
BeTheBall

 

Posts: 6356
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: Multiple Drop Down - All Value Option - 2/17/2004 22:37:28   
Try this code for the first dropdown. I tested it and it should work.

<select NAME="Make" SIZE="1" ONCHANGE=Form1.submit()>

<option selected>Select One</option>

<option value="%" <%If Request.Form("Make")="%" Then response.write("Selected") End If%>>All</option>
<!--#include file="_fpclass/fpdbrgn1.inc"-->
<option><%=FP_FieldHTML(fp_rs,"Make")%></option>
<!--#include file="_fpclass/fpdbrgn2.inc"-->
</select>

_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to 4ank)
4ank

 

Posts: 11
Joined: 2/11/2004
Status: offline

 
RE: Multiple Drop Down - All Value Option - 2/18/2004 0:22:06   
Thanks, I did that.
Edit - it works.
There are two more issues I want to address:

when I initially get to the page, there is nothing displayed in the "make" drop down even though in the code "Select One" is selected.

Also, when I change "Makes", it jumps to "Select One" (the value stays what i clicked on but the display says Select One).

Is there a way to set it up that the "Select One" will only come up the initial view time and then the selected make (once chosen) will stay on the display until changed?

Thanks again




It works, but the opposite of how I want it to.

The way it is, the user can:
1. browse by make and model (being that they know both)
2. browse by any make and a specific model (being that they know the model)(this i do not really care about)
3. browse entire inventory

what they can't do is:
Browse by a specific make and any model of that make(instead the result is all inventory)

This last part is what I really want. I want them to have to choose a make before the results of the models are shown. (or choose any make and any model and browse entire inventory)
Ex: if the user really likes BMW's, I would like them to be able to search for all the BMW's in stock.

I will play more with this tomorrow. Thanks again for your help.

< Message edited by 4ank -- 2/18/2004 0:31:42 >

(in reply to BeTheBall)
BeTheBall

 

Posts: 6356
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: Multiple Drop Down - All Value Option - 2/18/2004 9:42:24   
OK. You really made me work on this one. Try replacing from the first <form> tag to the second </form> tag with the following:

<form method="POST" name="Form1" action="Page1.asp">
<!--#include file="_fpclass/fpdblib.inc"-->
<%
fp_sQry="SELECT DISTINCT Make FROM Results"
fp_sDefault=""
fp_sNoRecords="No records returned."
fp_sDataConn="inventory"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=False
fp_fMenuFormat=True
fp_sMenuChoice="Make"
fp_sMenuValue="Make"
fp_iDisplayCols=1
fp_fCustomQuery=False
BOTID=0
fp_iRegion=BOTID
%>
<p><select NAME="Make" SIZE="1" ONCHANGE=Form1.submit()>

<option selected>Select One</option>

<option value="%" <%If Request.Form("Make")="%" Then response.write("Selected") End If%>>All</option>
<!--#include file="_fpclass/fpdbrgn1.inc"-->
<option <%If Request.Form("Make")=FP_Field(fp_rs,"Make") Then Response.write("selected")End If%>><%=FP_Field(fp_rs,"Make")%></option>
<!--#include file="_fpclass/fpdbrgn2.inc"-->
</select> </p>
</form>
<p> </p>

<form method="POST" name="form2" action="Page2.asp">
<p><nobr><!--#include file="_fpclass/fpdblib.inc"-->
<%
fp_sQry="SELECT DISTINCT Model FROM Results WHERE Make = '::Make::'"
fp_sDefault=""
fp_sNoRecords="No records returned."
fp_sDataConn="inventory"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=False
fp_fMenuFormat=True
fp_sMenuChoice="Model"
fp_sMenuValue="Model"
fp_iDisplayCols=1
fp_fCustomQuery=False
BOTID=0
fp_iRegion=BOTID
%>
<p><select NAME="Model" SIZE="1">
<%If Request.Form("Make")="%" Then%>
<option selected value="%">All</option>
<%Else%>
<option selected>Select One</option>
<option value="%" <%If Request.Form("Model")="%" Then Response.write ("selected") End If%>>All</option>
<!--#include file="_fpclass/fpdbrgn1.inc"-->
<option><%=FP_FieldHTML(fp_rs,"Model")%></option>
<!--#include file="_fpclass/fpdbrgn2.inc"-->
<%End If%>
</select>
</p>
<p><input type="submit" value="Go" name="B1">
</p>
<input type="hidden" name="Make" value="<%=Request.Form("Make")%>">
</form>

< Message edited by betheball -- 2/18/2004 8:20:57 >


_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to 4ank)
4ank

 

Posts: 11
Joined: 2/11/2004
Status: offline

 
RE: Multiple Drop Down - All Value Option - 2/18/2004 15:51:48   
You are the man. Thanks

Now, can you point me in the right direction of some (javascript) code for validation. Forinstance if the user hits the go button and "select one" is selected it returns a msg box.


Thanks a lot. Thanks for the help.

Frank

(in reply to BeTheBall)
BeTheBall

 

Posts: 6356
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: Multiple Drop Down - All Value Option - 2/18/2004 17:31:43   
quote:

Forinstance if the user hits the go button and "select one" is selected it returns a msg box.


Are you saying you want it to return a message box or that it is returning a message box?

If it's the former, you can do it quite easily in FrontPage. In Normal View, right-click your dropdown and select "Form Field Validation" Then, select the "Disallow First Choice" radio button and enter a name in the Display field. That will do it.

_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to 4ank)
BeTheBall

 

Posts: 6356
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: Multiple Drop Down - All Value Option - 2/18/2004 21:54:44   
I may have spoken too soon. The FP Validation seems to mess up the form. :) Here is a revised piece of code that doesn't use the "Select One" option.

<form method="POST" name="Form1" action="autos.asp">
<!--#include file="_fpclass/fpdblib.inc"-->
<%
fp_sQry="SELECT DISTINCT Make FROM Results"
fp_sDefault=""
fp_sNoRecords="No records returned."
fp_sDataConn="inventory"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=False
fp_fMenuFormat=True
fp_sMenuChoice="Make"
fp_sMenuValue="Make"
fp_iDisplayCols=1
fp_fCustomQuery=False
BOTID=0
fp_iRegion=BOTID
%>
<p><select NAME="Make" SIZE="1" ONCHANGE=Form1.submit()>

<option value="%" <%If Request.Form("Make")="%" Then response.write("Selected") End If%>>All</option>
<!--#include file="_fpclass/fpdbrgn1.inc"-->
<option <%If Request.Form("Make")=FP_Field(fp_rs,"Make") Then Response.write("selected")End If%>><%=FP_Field(fp_rs,"Make")%></option>
<!--#include file="_fpclass/fpdbrgn2.inc"-->
</select> </p>
</form>
<p> </p>
<form method="POST" name="form2" action="autos.asp">
<p><nobr><!--#include file="_fpclass/fpdblib.inc"-->
<%
fp_sQry="SELECT DISTINCT Model FROM Results WHERE Make = '::Make::'"
fp_sDefault=""
fp_sNoRecords="No records returned."
fp_sDataConn="inventory"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=False
fp_fMenuFormat=True
fp_sMenuChoice="Model"
fp_sMenuValue="Model"
fp_iDisplayCols=1
fp_fCustomQuery=False
BOTID=0
fp_iRegion=BOTID
%>
<p><select NAME="Model" SIZE="1">
<option value="%" <%If Request.Form("Model")="%" Then Response.write ("selected") End If%>>All</option>
<!--#include file="_fpclass/fpdbrgn1.inc"-->
<option><%=FP_FieldHTML(fp_rs,"Model")%></option>
<!--#include file="_fpclass/fpdbrgn2.inc"-->
</select>
</p>
<p><input type="submit" value="Go" name="B1">
</p>
<input type="hidden" name="Make" value="<%=Request.Form("Make")%>">
</form>

_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to BeTheBall)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> Multiple Drop Down - All Value Option
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts