ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 10th, 2004, 06:27 PM
tready29483 tready29483 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 4 tready29483 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Dynamic Drop Down List!

Ok,

I have a form I'm building in Dreamweaver. On my form I have a drop down list that is populated by a table in my Access Database. I won't to add a second drop down list but have the contents of it vary by what I select in my first drop down list. Let me explain further. Lets say I have a database of Movies. And The name of the movies are in a table and that table is used to populate my first drop down list. Now I have another table that has the actors in the movies. I have a junction table to make them relate in my database.....now how can I select a movie in the first drop down list...and the actors from that movie popluate the second drop down list???

Reply With Quote
  #2  
Old January 10th, 2004, 08:27 PM
txbakers txbakers is offline
webgeek
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: Dallas, TX, USA
Posts: 120 txbakers User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 17 sec
Reputation Power: 7
show the first drop down list as you do.

Make the onChange event of the drop down list submit a form, with the value of the list.

Have another recordset which takes that variable and calls for the second list.

Just be sure to hide the second list when the second recordset is "EOF"

If you need an example to look at I can provide one.

Reply With Quote
  #3  
Old January 10th, 2004, 10:41 PM
ladytjod ladytjod is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 1 ladytjod User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I would love to see your example.

Thanks

Reply With Quote
  #4  
Old January 11th, 2004, 10:33 AM
txbakers txbakers is offline
webgeek
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: Dallas, TX, USA
Posts: 120 txbakers User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 17 sec
Reputation Power: 7
OK, here is a quick sample of what I do, First, the two recordsets:

<%
var rsUniParts = Server.CreateObject("ADODB.Recordset");
rsUniParts.ActiveConnection = MM_connCharms_STRINGSQL;
rsUniParts.Source = "SELECT UniformItem FROM UniformParts WHERE schCode = '"+ scode + "' ORDER BY UniformItem ASC";
rsUniParts.CursorType = 0;
rsUniParts.CursorLocation = 2;
rsUniParts.LockType = 3;
rsUniParts.Open();
%>


this one brings back a list of categories for that user (scode).

<%
var rsUniitems = Server.CreateObject("ADODB.Recordset");
rsUniitems.ActiveConnection = MM_connCharms_STRINGSQL;
rsUniitems.Source = "SELECT itemno, size, condition,rrn FROM UniformDetail WHERE SchCode = '"+ scode + "' and UniformItem = '" + unitype + "' and (assignedto = 'x' or assignedto is null) ORDER BY itemno ASC";
rsUniitems.CursorType = 0;
rsUniitems.CursorLocation = 2;
rsUniitems.LockType = 3;
rsUniitems.Open();

%>


this one brings back a list of items in that category which haven't been assigned. The red code above takes the unitype variable from the first drop down list.


Now the HTML:

Here is the first drop down box:

<select name="unicat" onChange="getItems(this);" class="inputbox">
<option value="">Select Part</option>
<%while (!rsUniParts.EOF){%>
<option value="<%=(rsUniParts.Fields.Item("UniformItem").Value)%>" ><%=(rsUniParts.Fields.Item("UniformItem").Value)%></option>
<%rsUniParts.MoveNext();} %>
</select>


The second drop down box looks like this:

<% if (!rsUniitems.EOF ) { %>
<select name="recordnumber" class="inputbox" onChange="document.partform.submit(); ">
<option selected>Select Item Number</option>
<%while (!rsUniitems.EOF){%>
<option value="<%=(rsUniitems.Fields.Item("rrn").Value)%>"><%=(rsUniitems.Fields.Item("itemno").Value)%> - size <%=(rsUniitems.Fields.Item("size").Value)%></option>
<%rsUniitems.MoveNext();} %>
</select>


Of course there is more HTML around it, tables, etc. But this should get you going in the right direction. I don't actually submit a form on the first drop down, but call a javascript function which sends that value to the QueryString. If you don't want to use javascript, you could just as easily submit a form.

If you want to see a working example, I'll have to refer you to a URL which I'm not sure we can post here.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Dynamic Drop Down List!


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT