473,396 Members | 1,918 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Creating a dynamic drop down menu

I have 2 dynamic PHP dropdowns:

The second dropdown populates from the first, depending on what is selected in the first.
The page is showing issues in a department:

The first dropdown consists of departments- It has 3 options All issues, dept A, dept B
If dept A is chosen in the first dropdown, the second dropdown shows all members in dept A and all issues are shown for dept A are shown below.

Now if i choose a member in second dropdown, i want issues owned by this member to show up.

code:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. //db connection file goes here
  4.  
  5.  
  6.  
  7. if (isset($_GET["first"]))
  8. {
  9.     $first =$_GET["first"];
  10.  
  11.  
  12. }
  13. if (isset($_GET["second"]))
  14. {
  15.     $second =$_GET["second"];
  16.  
  17. }
  18.  
  19. ?>
  20. <HTML>
  21.  
  22. <script language="JavaScript">
  23.  
  24. function mySubmit()
  25. {
  26.     var formObject = document.forms['myform'];
  27.     formObject.submit();
  28. }
  29.  
  30.  
  31. <?php
  32.  
  33. </HEAD>
  34. <BODY>
  35.  
  36. <form name="myform" method="get">
  37.  
  38.         <p>Please select a dept 
  39.     <select name="first"  onChange ="mySubmit();">
  40. <option value="NULL"></option>
  41. <?php
  42.     //get members from db depending on what dept is selected
  43.  
  44.  echo '</SELECT>';
  45.  
  46. if($first != null) 
  47.     { 
  48.  
  49.     ?> 
  50.     Please select a member:&nbsp;
  51.     <select name="second" onChange="mySubmit();">        
  52.  
  53.  //get option values from db
  54.  echo '</SELECT>';
  55.  
  56. }
  57.  
  58. //if dept selected show issues for that dept
  59. //if member selected show issues only for that member
  60.  
  61.  
  62. </TABLE>
  63. </BODY>
  64. </HTML>
  65.  
Any help is appreciated.

Thank you.
Aug 25 '07 #1
1 1876
pbmods
5,821 Expert 4TB
Heya, PHP Newbie.

There are over a dozen threads on this site that cover exactly what you are looking for.

Head over to the search page and search the PHP forum for 'dynamic drop down'.
Aug 26 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: jorntk | last post by:
How can i make a drop down menu that are dynamiclly generated base on the value selected in another drop down menu? thanks nad regards Jorn
6
by: Greg Scharlemann | last post by:
I am attempting to populate a drop down menu based on the selection of a different drop down menu. However, it is not working correctly, I cannot figure out for the life of me what exactly happens...
9
by: Harry | last post by:
I am accumulating over 80 pages per day into an archive that I will need to be able to present sequentially to viewers. Using html to viewing a page, then click on back to return to my archive...
1
by: tribal boy | last post by:
Guys, I am using a dynamic menu which uses xml,xsl a css file and javascript. This works fine when there are no server controls around or underneath it. The problem is whenever the menu...
19
by: mart2006 | last post by:
I've created a dynamic drop down menu that populates itself with data from a MySQL table. What I would like to do is create a non dynamic drop down menu that alters what is shown in the dynamic menu....
9
by: Tarscher | last post by:
hi all, I have this seemingly simple problem. I have lost a lot of time on it though. When a user selects a value from a dropdownlist (static control) a dynamic control is generated. I have...
4
by: TycoonUK | last post by:
Hi, As I do not have IE7 on my computer, I was wondering if there is a fault in my CSS Menu when using IE7. Please can someone look at my site - http://www.worldofmonopoly.co.uk and tell me...
1
by: azeemqaiser | last post by:
Hi All, I have a form with two drop down controls. I want to change the values of Drop Down Menu 2 if i select some value in Drop Down Menu 1. Like If i select country then all the states of...
2
by: vinceboy | last post by:
Hi anybody. I am newbie here and would like to know that how can I validate both drop down menu and radio button from a dynamic display form.Something went wrong with my script.The radio button is...
10
by: mart2006 | last post by:
Hi, I'm fairly new to PHP and I've created a dynamic drop down menu that populates itself with data from a MySQL table. What I would like to do is create a non dynamic drop down menu that alters...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.