Re: [PHP] php hide menu
At 12:12 PM -0500 6/7/11, Chris Stinemetz wrote: > Chris: You mean something like this? http://php1.net/b/zipcode-states/ The explanation (and js) is there. Yes, do you have a tutorial to go with the demo? Thank you, The demo is a tutorial. The javascript code is there -- just download it. The code to populate the selection boxes is very similar to this: http://www.php1.net/b/form-checkbox1/ From those two, you should be able to make your way. After all, that's what I did. Cheers, tedd PS: Also, please reply to the list and not me. -- --- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php hide menu
At 11:40 PM -0500 6/6/11, Chris Stinemetz wrote: I have three drop down menus in my form. How do I make it so the second and third menus are only visible once the prior menu was selected? Chris: You mean something like this? http://php1.net/b/zipcode-states/ The explanation (and js) is there. The back-end php is simply looking through database to populate the "second selection control" based upon selection of the first; and then populates the "third selection control" based upon the selection of the second. It's not that complicated -- just take baby steps. Cheers, tedd -- --- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] php hide menu
[snip] I would like to pass the value from the prior menu to the next. Would you please show me how to handle this? [/snip] As several have mentioned, this is a job for AJAX and JavaScript. Here is a good tutorial: http://www.yourinspirationweb.com/en/how-to-create-chained-select-with-p hp-and-jquery/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php hide menu
> If you do require the value from the first menu to be passed to the select > statements for the other menus let me know I will explain how that is done, > it is a little more complex. > I would like to pass the value from the prior menu to the next. Would you please show me how to handle this? Thank you, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] php hide menu
Dynamically changing displays can be done with JavaScript. First thing I want you to think of is whether or not your 2nd and 3rd menus require information from the first menu to display or sort. According to what I see they do not. If they do not : We start off wrapping each of the second and 3rd menus in a DIV element and turning them off to display. I am using 2 options pick which one is best for you. We can display them individually by "ID" or by the group of "class". Now we give an ID attribute to the first menu. echo "Choose Market\n"; Put your 2nd menu in here Put your 3nd menu in here In this example I will utilize JQuery.js IF you do not have it you can download it from www.jquery.com . Please do not use both function if you use a class use the class if you use and ID base use the ID $(document).ready(function(){ // this will display them by ID $('#market').change( Function() { Val marketvalue = $(This).val(); // I am doing this because what if they change the menu back to the default value of '' If(marketvalue >= 1) { $('#Menu2').show(); $('#Menu3').show(); }else{ $('#Menu2').hide(); $('#Menu3').hide(); } } ); // this will display them by the class $('#market').change( Function() { Val marketvalue = $(This).val(); // I am doing this because what if they change the menu back to the default value of '' If(marketvalue >= 1) { $('.other_menus').show(); }else{ $('.other_menus').hide(); } } ); }); This will display the menu items as soon as they pick from the first menu NOT requiring a submit. If you do require the value from the first menu to be passed to the select statements for the other menus let me know I will explain how that is done, it is a little more complex. Richard L. Buskirk -Original Message- From: Chris Stinemetz [mailto:chrisstinem...@gmail.com] Sent: Tuesday, June 07, 2011 12:41 AM To: php-general@lists.php.net Subject: [PHP] php hide menu I have three drop down menus in my form. How do I make it so the second and third menus are only visible once the prior menu was selected? Below is the first two drop down menus. Thanks in advance. // Generating first menu using array. $markets = array('MCI' => 'Kansas City', 'STL' => 'ST. Louis', 'ICT' => 'Wichita', 'OMA' => 'Omaha', 'LIN' => 'Lincoln'); echo "Choose Market\n"; foreach ($markets as $key => $market) { echo "$market\n"; } echo ""; // This will evaluate to TRUE so the text will be printed. if (isset($markets)) { echo "This var is set so I will print."; } // Then, later, validating the menu if (! array_key_exists($_POST['Market'], $choices)) { echo "You must select a market."; } $query="SELECT cell_sect FROM sector_list order by cell_sect"; $result = mysql_query ($query); echo "Choose Cell Sector"; // printing the list box select command while($cellSect=mysql_fetch_array($result)){//Array or records stored in $cellSect echo "$cellSect[cell_sect]"; /* Option values are added by looping through the array */ } echo "";// Closing of list box // This will evaluate to TRUE so the text will be printed. if (isset($cellSect)) { echo "This var is set so I will print."; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php hide menu
Sounds like a good job for client side JavaScript. Regards, -Josh Joshua Kehn | josh.k...@gmail.com http://joshuakehn.com On Jun 7, 2011, at 12:40 AM, Chris Stinemetz wrote: > I have three drop down menus in my form. How do I make it so the > second and third menus are only visible once the prior menu was > selected? > > Below is the first two drop down menus. > > Thanks in advance. > > // Generating first menu using array. > $markets = array('MCI' => 'Kansas City', > 'STL' => 'ST. Louis', > 'ICT' => 'Wichita', > 'OMA' => 'Omaha', > 'LIN' => 'Lincoln'); > echo "Choose Market\n"; > foreach ($markets as $key => $market) { > echo "$market\n"; > } > echo ""; > > // This will evaluate to TRUE so the text will be printed. > if (isset($markets)) { >echo "This var is set so I will print."; > } > > > > // Then, later, validating the menu > if (! array_key_exists($_POST['Market'], $choices)) { > echo "You must select a market."; > } > > $query="SELECT cell_sect FROM sector_list order by cell_sect"; > > $result = mysql_query ($query); > echo "Choose Cell Sector"; > // printing the list box select command > > while($cellSect=mysql_fetch_array($result)){//Array or records stored > in $cellSect > echo "$cellSect[cell_sect]"; > /* Option values are added by looping through the array */ > } > echo "";// Closing of list box > > // This will evaluate to TRUE so the text will be printed. > if (isset($cellSect)) { >echo "This var is set so I will print."; > } > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php hide menu
I have three drop down menus in my form. How do I make it so the second and third menus are only visible once the prior menu was selected? Below is the first two drop down menus. Thanks in advance. // Generating first menu using array. $markets = array('MCI' => 'Kansas City', 'STL' => 'ST. Louis', 'ICT' => 'Wichita', 'OMA' => 'Omaha', 'LIN' => 'Lincoln'); echo "Choose Market\n"; foreach ($markets as $key => $market) { echo "$market\n"; } echo ""; // This will evaluate to TRUE so the text will be printed. if (isset($markets)) { echo "This var is set so I will print."; } // Then, later, validating the menu if (! array_key_exists($_POST['Market'], $choices)) { echo "You must select a market."; } $query="SELECT cell_sect FROM sector_list order by cell_sect"; $result = mysql_query ($query); echo "Choose Cell Sector"; // printing the list box select command while($cellSect=mysql_fetch_array($result)){//Array or records stored in $cellSect echo "$cellSect[cell_sect]"; /* Option values are added by looping through the array */ } echo "";// Closing of list box // This will evaluate to TRUE so the text will be printed. if (isset($cellSect)) { echo "This var is set so I will print."; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php