tommy168 Posted March 8, 2011 Share Posted March 8, 2011 Hi guys So i am having a problem with the drop down menu For example, when you click the option "other" from the menu, it will prompt you with an additional text box, as you can see from the script below: <tr> <td valign="top" class="formLabelsS2"><div align="right">Genetic Background: </div></td> <td><select name="genetic_bg[]" size="5" multiple="multiple" class="basicMenu" id="genetic_bg" onChange="toggleOther('genetic_bg','GeneticBGOther','GeneticBGOtherTxt');" > <?php menu_display("genetic_bg"); ?> </select> </td> </tr> <tr id="GeneticBGOther" <?php menu_display_other("genetic_bg");?>> <td class="formLabelsS2"><div align="right">Other</div></td> <td><span class="body"> <input name="GeneticBGOtherTxt" type="text" class="basicTextField" id="GeneticBGOtherTxt" value="<?php echo $_GET['GeneticBGOtherTxt']; ?>" size="35" /> </span></td> </tr> The scripts for menu_display and menu_display_other functions are as follow: function menu_display($menu_name){ $menu = menu_get_menu($menu_name); if($_SERVER['REQUEST_METHOD'] == 'POST') { $method = $_POST; } else { $method = $_SESSION; } if(!empty($menu)){ for($i=0;$i<sizeof($menu);$i++){ //we add the label for javascript showing and hiding divs echo "<option value={$menu[$i]['value']} label=\"{$menu[$i]['title']}\""; if(is_array($method[$menu_name])){ if(in_array($menu[$i]['value'],$method[$menu_name])){ echo "selected=\"selected\"" ; } } else { if($method[$menu_name] == $menu[$i]['value']) { echo "selected=\"selected\"" ; } } echo ">{$menu[$i]['title']}</option><br />"; } } } /* This function checks if the variable $str is in recieved data if not the element is hidden input: select id */ function menu_display_other($menu_name) { $conn = db_connect_2(); if($_SERVER['REQUEST_METHOD'] == 'POST') { $method = $_POST; } else { $method = $_SESSION; } if($menu_name == 'ana_stage'){ $query = "SELECT STG_OID FROM ana_stage WHERE STG_NAME = 'Other';"; } else { $prefix = get_table_prefix($menu_name); $query = "SELECT {$prefix}_ID FROM $menu_name WHERE {$prefix}_NAME = 'Other';"; } $result = $conn->query($query); $row = $result->fetch_array(); $str = $row[0]; if(isset($method[$menu_name])) { //check if it is an array if(is_array($method[$menu_name])) { //check if $str is in the array if(in_array($str, $method[$menu_name])) { //return, the element is displayed return true; } } //not array elseif($method[$menu_name] == $str) { return true; } } // finally hide the element since $str was not selected as one of the options echo "style=\"display:none\""; $conn->close(); } Yes the drop down menu works fine in the original script..... UNTIL i transfer these codes into other scripts I basically use the exact same codes, but somehow the menu is not doing the same thing when I click the "other" option as before in the original script, or in other word, no additional text box is prompted and basically no response what so ever By the way, i included all the necessary scripts. So what causes this problem? Any help is appreciated Quote Link to comment https://forums.phpfreaks.com/topic/230029-menu-problems/ Share on other sites More sharing options...
tommy168 Posted March 9, 2011 Author Share Posted March 9, 2011 Here's the URL to the page of the menu, so you can sort of visualize more: http://nagy.mshri.on.ca/Coop_Student/cre/search/Search_Coop_try3.php As you can see, the genetic background menu in the Advanced Search section works like it is supposed to. When you click the "other" option on the drop down menu there (scroll down to the bottom of the menu), it will prompt you to an additional text box But if you compare it with the genetic background menu at the bottom in the update mailing list section, when you click "other", nothing happens... Again, i used the exact same code (copy and paste pretty much as you can see above) and the script for update mailing list is INCLUDED into the main script of the search page, so all the scripts needed for menu to work are all there So what's the problem? By the way, i removed the submit button for update mailing list cause i am still building the script Thanks Quote Link to comment https://forums.phpfreaks.com/topic/230029-menu-problems/#findComment-1185020 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.