Solved

Dynamic Drop Down Menu Changes 2nd Drop Down Menu

Posted on 2011-03-06
8
865 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

730 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