Solved

Dynamic Drop Down Menu Changes 2nd Drop Down Menu

Posted on 2011-03-06
8
861 Views
Last Modified: 2012-05-11
I have two dynamic drop down menus populated using two recordsets.  The second drop down is filtered based on the selection in the first drop down and is intended to display its selection on the page.  I'm using dreamweaver to make the page and have limited actual coding experience leading to my confusion.  From viewing other questions and responses, it appears I need some javascript and an onchange command.  I haven't been able to determine the proper code or if I'm missing something else.  I will attach the page for viewing.

My two tables are FoodGroups and FoodNames.  The FoodGroup table has two columns Food_Group_ID and Group_Name.  The FoodNames table has Food_Group_ID and Food_Name.  My filter variable is Food_Group_ID.  What I'm missing appears to be how to submit the variable to the second recordset.  

The last question is once the second list is populated, will I use the same method/code to select what's  displayed on the page.  

Thanks for any help.

testdropdown.php
0
Comment
Question by:novdoc
  • 4
  • 2
  • 2
8 Comments
 
LVL 3

Expert Comment

by:wwwdeveloper2
ID: 35051157
I looked at your code, but had a little time following it.

Here is basically what I know should work:

Go ahead and do your query and populate selection 1
Have selection post back to the page and assign it's value to a variable such as $selection1

I would have an if condition below the first selection in the page.  I wouldn't keep them both on the top of the page, like you current do.

if ($selection1 != "") //checking to see if selection has been made in the first drop down
{
 
Do your query here for the new drop down select based on your $selection1 variable

Build/Populate the drop down select from the returned query results

}


Let me know what questions you might have.  Looks like you are already doing very well for a beginner.  Good luck!
0
 

Author Comment

by:novdoc
ID: 35053300
Thanks for your quick reply.  It will take me a while to sort through what you've recommended.  Sorry about the trouble following the code.  It basically is what Dreamweaver does.  

I understand what you're suggesting about the value variable and will look at it.  Don't I need to submit something when the menu1 item is selected?  Is this what you're referring to by having selection post back to page?
0
 
LVL 3

Assisted Solution

by:wwwdeveloper2
wwwdeveloper2 earned 250 total points
ID: 35063593
novdoc -

Yes when you make a selection in the list 1, it should post back to the page and you can put your post selection value into a variable.

Then you jump into the condition where the variable isn't null and it will build the second list menu with the new query where your condition meets what is in the variable.

Just let me know what questions you may have.  I'll help you out in any way I can.

Good luck.
0
 
LVL 70

Assisted Solution

by:Jason C. Levine
Jason C. Levine earned 250 total points
ID: 35066893
novdoc,

If you don't want to learn the code to do this and instead just want a DW-specific solution, you can purchase an extension to automate the process:

http://www.webassist.com/dreamweaver-extensions/dynamic-dropdowns/

If you want to get down and dirty in the code, I recommend this tutorial/demo as a good starting point:

http://www.plus2net.com/php_tutorial/php_drop_down_list.php
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:novdoc
ID: 35077970
I appreciate both the above comments.  While I think I understand the concept to post the variable and reload the page, I don't know enough code to make it work.  The examples I've been able to find for review all seem to take a different approach to solve the issue.  

Currently, I'm working with a dreamweaver extension I found to see if I can make it work.  I'll post another comment after this effort to notify of status.  

Thanks
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 35078369
>> The examples I've been able to find for review all seem to take a different approach to solve the issue.  

There is no one, true method to make it work.  You can do it with AJAX or without.  With javascript or without.
0
 

Accepted Solution

by:
novdoc earned 0 total points
ID: 35103059
I went another direction and got it to work.  Ended up using a dreamweaver extension from Tecnorama.  Thanks for the responses.
0
 

Author Closing Comment

by:novdoc
ID: 35135956
Found solution with extension
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
This article discusses four methods for overlaying images in a container on a web page
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now