Wrox Programmer Forums
|
ASP Pro Code Clinic As of Oct 5, 2005, this forum is now locked. No posts have been deleted. Please use "Classic ASP Professional" at: http://p2p.wrox.com/forum.asp?FORUM_ID=56 for discussions similar to the old ASP Pro Code Clinic or one of the other many remaining ASP and ASP.NET forums here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Pro Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 7th, 2004, 12:30 PM
Authorized User
 
Join Date: Nov 2004
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
Default ASP Dynamic Drop Down???

I have an application that I am attempting to build that when an item from a dropdown list is selected, would fire off a different sql query that is dependant on the item chosen in the initial dropdown form. I really don't know where to start with this problem, as it has to be repeated 10 times if data is present to populate other form fields. Please Help!!!

 
Old December 7th, 2004, 05:47 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Sounds like you need an onChange event in your <select> tag. Something like:
OnChange submit the form and reload the page rendering sql relating to the selection chosen?

The following would be an example of lets say a product listing page. We have a bit field in the products table called 'inactive' When the page runs initialy the ELSE condition runs showing all active products. If we choose 'Show Inactive Products' from the select list the page reloads and runs the if condition showing all inactive products.

<% if request.form("displayType") <> "" then
       sql = "SELECT ..... FROM Products WHERE inactive=" & request.form("displayType") & ";"
    else
       sql = "SELECT ..... FROM Products WHERE inactive=0"
    end if
%>


<FORM NAME="displayForm" METHOD="Post" ACTION="somePage.ASP">
 <SELECT NAME="displayType" SIZE="1" onChange="Javascript:displayForm.submit();">
  <option vlaue="0">Show Active Products</option>
  <option value="1">Show Inactive Products</option>
 </SELECT>
</form>

Wind is your friend
Matt
 
Old December 7th, 2004, 09:26 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 344
Thanks: 0
Thanked 1 Time in 1 Post
Default

If the data is small enough to be handled client side then something like http://www.greggriffiths.org/webdev/...nkeddropdowns/ may work for you.

alternatively you may have to do a POST / GET back to the server of the entire page - or you could use a hidden IFrame - or just use XML.
 
Old December 8th, 2004, 01:08 PM
Authorized User
 
Join Date: Nov 2004
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Both of these solutions work great, but what about repeating the process 10 times with just one initial selection box. When one selects an item in dropdown box "A" then all ten Dropdown boxes ("B")need to show the same selections dependant on "A"?

 
Old December 8th, 2004, 05:52 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

busher

Seems I mis understood your post. You want to populate other selection boxes not page content? Both ways would work, if you’re not proficient in JS the way I suggested would be easier to code however Greg’s suggestion would be more resources efficient. May I suggest you have a go at building the page, if and when you get stuck the helpful people around here I'm sure will assist you.


Wind is your friend
Matt





Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic drop down list bart.moons Classic ASP Databases 9 January 25th, 2005 10:05 AM
.asp.net dynamic drop down menu fitchic77 .NET Framework 2.0 2 August 12th, 2004 07:39 PM
Dynamic drop-down list lucian Dreamweaver (all versions) 2 July 8th, 2004 05:58 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.