Solved

Dynamic Drop Down Menu Changes 2nd Drop Down Menu

Posted on 2011-03-06
8
866 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 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
What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

 
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
 

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

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

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

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

728 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