Solved

Dynamic Drop Down Menu Changes 2nd Drop Down Menu

Posted on 2011-03-06
8
863 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Javascript_Set_dropdown_value 7 34
How do I fix this UPDATE error? 7 24
key press alert 2 19
VBScript on Html 11 20
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
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.
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 the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

832 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