?
Solved

Dynamic Drop Down Menu Changes 2nd Drop Down Menu

Posted on 2011-03-06
8
Medium Priority
?
867 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1000 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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
LVL 70

Assisted Solution

by:Jason C. Levine
Jason C. Levine earned 1000 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
 

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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This article discusses how to create an extensible mechanism for linked drop downs.
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 look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

771 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