Results 1 to 7 of 7

Thread: Help with dynamic drop down menu

  1. #1
    Join Date
    Jun 2010
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Help with dynamic drop down menu

    Hi has anyone had any trouble implementing the code for the dynamic drop down menu in php. I have tried to do this but when i rollover the first drop down nothing will happen except you can click on the header link

  2. #2
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default

    Really need more context to understand what the problem is, have you got any code you can show us?

    Here's how you could make one from an array in its simplest form:

    PHP Code:
    <select>
    <?php
    $array 
    = array('Item one''Item two');

    foreach(
    $array as $item) {
     echo 
    "<option>{$item}</option>";
    }
    ?>
    </select>
    I'm guessing you're using a database though, so we'll need to see more code to be able to help.

  3. The Following User Says Thank You to Schmoopy For This Useful Post:

    bowser (07-05-2010)

  4. #3
    Join Date
    Jun 2010
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    this is the code for the whole page:
    Code:
    ?>
    <html>
    <head>
    <title>Company :: <?php echo decode_modulehandler(TITLE, True); ?></title>
    
    
    <meta name="Expires" content="never">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="verify-v1" content="xeALQzAx7BW7c5+nQ2+U3Rer3ntkQekT8R4B9CiI1xc=" />
    <link href="./css/thestyle.css" rel="stylesheet" type="text/css">
    <link rel="stylesheet" type="text/css" href="./css/chromestyle.css" />
    <script type="text/javascript" src="autoTab.js"></script>
    
    <script type="text/javascript" src="chrome.js"></script>
    <style type="text/css">
    <!--
    .style2 {color: #FFFFFF}
    -->
    </style>
    <script type="text/JavaScript" src="./script/preload.js"></script>
    <script type="text/JavaScript" src="imageswap.js"></script>
    <script type="text/JavaScript">
    <!--
    <!--
    function MM_preloadImages() { //v3.0
      var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
        var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
        if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    }
    //-->
    function showhide(id){
    if (document.getElementById){
    obj = document.getElementById(id);
    if (obj.style.display == "none"){
    obj.style.display = "";
    } else {
    obj.style.display = "none";
    }
    }
    }
    
    function MM_jumpMenu(targ,selObj,restore){ //v3.0
      eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
      if (restore) selObj.selectedIndex=0;
    }
    
    <!--
    function changeImage(a,b)
    {
      var c = './images/' + b ;
      document.images[a].src= c;
      return true;
    }
    function changeImageBack(a,b) 
    {
       	var c = 'images/' + b ;
       	document.images[a].src = c;
       	return true;
    }
     
    //-->
    </script>
    </head>
    
    <body>
    
    <table align="center" border="0" cellpadding="0" cellspacing="0" width="814">
      <tbody><tr>
        <td>
    
        <img src="images/top_banner2.gif" width="813" height="96" border="0" usemap="#Map2">    <div style="position: absolute; top: 2px; right: 5px;">
            <!-- Embedded WhosOn : Insert the script below at the point on your page where you want the Click To Chat link to appear -->
                   <SCRIPT language="Javascript" type="text/javascript" src="./whoson_utility_advice_bureau.js"></SCRIPT>
            <!-- End of embedded WhosOn -->
        </div>    </td>
      </tr>
        <tr>
    	        <?php if($session->isAdmin()){
    			if(MODULE != "admin") {
    				echo "<form action=\"./index.php?module=" .MODULE. "&action=update\" method=\"POST\">";
    			}?>
    	<td>&nbsp;</td>
    	</tr>
    	<tr>
    				  <td background="./images/admin_bg.gif" width="815" class="padding">
    
    				<p class="normal" align="center">
    			  <?php
    			if(MODULE != "admin") {
    				echo 'Page Title: '  . decode_modulehandler(TITLE);
    			}
    			?>
    				  <br>
    				  <a href="./index.php?module=about">About Us-Temp_link</a> | <a href="./index.php?module=admin">View Administration</a> | <a href="./process.php">Logout</a></p>	  </td>
    				</tr>
    			<?php } ?>
        <tr>
        <td align="center"></td>
      </tr>
      <tr><td>&nbsp;</td></tr>
      <tr>
        <td>
    
    <div class="chromestyle" id="chromemenu">
    <table background="images2/menu_back2.gif" width="800">
    <ul>
    <tr><td><li><a href="#" rel="dropmenu1"><img border="0" src="images2/home.gif"></a></li></td>
    <td><li><a href="#" rel="dropmenu2"><img border="0" src="images2/home2.gif"></a></li></td>
    <td><li><a href="#" rel="dropmenu3"><img border="0" src="images2/home3.gif"></a></li></td>
    <td><li><a href="#" rel="dropmenu4"><img border="0" src="images2/home4.gif"></a></li></td>
    </ul>
    </tr>
    </div>
    
    <!--1st drop down menu -->                                                   
    <div id="dropmenu1" class="dropmenudiv">
    <a href="http://www.dynamicdrive.com/">Dynamic Drive</a>
    <a href="http://www.cssdrive.com">CSS Drive</a>
    <a href="http://www.javascriptkit.com">JavaScript Kit</a>
    <a href="http://www.codingforums.com">Coding Forums</a>
    <a href="http://www.javascriptkit.com/jsref/">JavaScript Reference</a>
    </div>
    
    <!--2nd drop down menu -->                                                
    <div id="dropmenu2" class="dropmenudiv2" style="width: 150px;">
    <a href="http://www.cnn.com/">CNN</a>
    <a href="http://www.msnbc.com">MSNBC</a>
    <a href="http://news.bbc.co.uk">BBC News</a>
    </div>
    
    <!--3rd drop down menu -->                                                   
    <div id="dropmenu3" class="dropmenudiv3" style="width: 150px;">
    <a href="http://www.google.com/">Google</a>
    <a href="http://www.yahoo.com">Yahoo</a>
    <a href="http://www.msn.com">MSN</a>
    </div>
    
    <div id="dropmenu4" class="dropmenudiv4" style="width: 150px;">
    <a href="http://www.google.com/">Google</a>
    <a href="http://www.yahoo.com">Yahoo</a>
    <a href="http://www.msn.com">MSN</a>
    </div>
    
    <script type="text/javascript">
    
    cssdropdown.startchrome("chromemenu")
    
    </script>
    </table>
    	</td>
      </tr>
      <tr>
        <td>
    </td>
      </tr>
      <?php if(MODULE === "main") { ?>
      <tr>
        <td>
        	<div align="center"><span class="normal"><br></span>
        	
        	<!-- Original Code //
              <img src="./images/packages.gif" width="813" height="228" border="0" usemap="#Map">
              
            !-->
            <!-- Start Of Modification !-->
            <table width="813" cellspacing="0" cellpadding="0" background="./images/packages.gif" style="height:228px; border:0;">
            	<tr>
            		<td width="206" valign="bottom" align="right">
            			<a href="./index.php?module=holding-red" onmouseover="return changeImage('pod1','pods_over_01.gif')" onmouseout="return changeImageBack('pod1','pods_01.gif')"><img src="./images/pods_01.gif" border="0" name="pod1" id="pod1"></a></td>
            		<td width = "199" valign="bottom" >	
            	        <a href="./index.php?module=holding-blue" onmouseover="return changeImage('pod2','pods_over_02.gif')" onmouseout="return changeImageBack('pod2','pods_02.gif')"><img src="./images/pods_02.gif" border="0" name="pod2" id="pod2"></a></td>
            		<td width = "201" valign="bottom" >	
            	        <a href="./index.php?module=holding-green" onmouseover="return changeImage('pod3','pods_over_03.gif')" onmouseout="return changeImageBack('pod3','pods_03.gif')"><img src="./images/pods_03.gif" border="0" name="pod3" id="pod3"></a></td>
            		<td align="left" valign="bottom" >	
            	        <a href="./index.php?module=holding-yellow" onmouseover="return changeImage('pod4','pods_over_04.gif')" onmouseout="return changeImageBack('pod4','pods_04.gif')"><img src="./images/pods_04.gif" border="0" name="pod4" id="pod4"></a></td>
            	</tr>
            	
            </table>	
            <!-- Finish of Modifications !-->	  
         </div></td>
      </tr><?php } else { ?>
      <tr>
        <td><div align="center"><span class="normal">                       <br>
              <img src="./images/table_top.gif" width="813" height="19" border="0"></span></div></td>
      </tr>
        <?php } ?>
      <tr>
    <td class="content_bg" align="center" valign="top" width="813">
    	<?php
            // Load module content as a function, this allows the module to run php and not just load text
            content();
            ?>
        <?php if($session->isAdmin() && MODULE != "admin" && MODULE != "half_quote" && MODULE != "elec_quote" && MODULE != "gas_quote" && MODULE != "holding-blue" && MODULE != "corporate_quote" && MODULE != "corporate_callback" && MODULE != "holding-green" ){
    	echo "<input type=\"submit\" value=\"Apply Changes\"></form>";
    	} ?>
          <TABLE WIDTH=750 BORDER=0 CELLPADDING=0 CELLSPACING=0>
            <TR>
              <td class="dots" height="8"></td>
            </TR>
          </TABLE>
          <p class="subtitle_blue" align="center">Copyright &copy 2010 Utility Advice Bureau Limited (Co reg no 5716020)</p>
            <span class="style2">.</span>
          </p>
          </td>
      </tr>
    </tbody></table>
    	<p style="display:none">
    	<img src="./images/pods_over_01.gif" style="display:none">
    	<img src="./images/pods_over_02.gif" style="display:none">
    	<img src="./images/pods_over_03.gif" style="display:none">
    	<img src="./images/pods_over_04.gif" style="display:none">
    	</p>
    </body></html>
    on the page it seems to display ok, but when you roll over the mages nothing happens except that you can clock on the head of the list.

    thanks

  5. #4
    Join Date
    Jun 2010
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    this code should be at the start of the code submitted above

    Code:
    <?php
    define('blank', ' ');
    
    if($session->isAdmin()){
    	require "./php/modulehandler.php";
    	// Retrieve module name from querystring
    	if (!isset($_GET["module"])) {
    		$module_to_edit = "main";
    	} else {
    		$module_to_edit = $_GET["module"];
    	}
    	// Check to see if module exists
    	// If module === "template" then load the template file for editing
    	if ($module_to_edit === "template") {
    		$file_to_edit = $templatefilename;
    	} else {
    		$file_to_check = $pathtomodule . $module_to_edit . $moduleextension;
    		if (file_exists($file_to_check)) {
    			$file_to_edit = $file_to_check;
    		} else {
    			echo "Module does not exist";
    			return;
    		}
    	}
    
    	$module = new modulehandler;
    	$module->module_to_edit = $file_to_edit;
    	if (!$module->loadmodule()) {
    		$return_text .= "ERROR ON MODULE LOAD";
    	}
    	if (!$module->loaddefine()) {
    		$return_text .= "ERROR ON DEFINE LOAD";
    	}
    	if (isset($_GET["action"])) {
    		//Update file
    		foreach($_POST as $key => $value) {
    			if ($key != "editmodule") {
    				$result = $module->writenewdefine($key, $value);
    			}
    		}
    		//Reload file, due to update
    		if (!$module->loadmodule()) {
    			$return_text .= "ERROR ON MODULE LOAD";
    		}
    		if (!$module->loaddefine()) {
    			$return_text .= "ERROR ON DEFINE LOAD";
    		}
    		header("Location: ./index.php?module=" .$module_to_edit);
    	}
    
    	foreach($module->define_of_module as $key => $value) {
    		$one_line = false;
    		if (substr($key,-2) === "OL") {
    			$one_line = true;
    		}elseif ($key == "TITLE") {
    			$one_line = true;
    		}
    		if (strlen($value) > 100) {
    			$width="40";
    		} else {
    			$width="16";
    		}
    		if ($one_line) {
    			$page_text[$value] = "<input type=\"text\" name=\"$key\" value=\"$value\">";
    		} else {
    			$page_text[$value] = "<textarea name=\"$key\" cols=\"$width\" rows=\"5\">$value</textarea>";
    		}
    	}
    }
    
    function decode_modulehandler($enc_const, $is_title = false) {
    	global $session;
    	if($session->isAdmin() && MODULE != "admin"){
    		global $page_text;
    		if (!$is_title) {
    			$enc_const = $page_text[rawurldecode($enc_const)];
    		}
    	}
    	$enc_const2 = str_replace("%0D%0A", "<BR>", $enc_const);
    	return rawurldecode($enc_const2);

  6. #5
    Join Date
    Jun 2010
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    i have implemented this code in html, but it will not work in php, can anyone help please

  7. #6
    Join Date
    Jul 2010
    Location
    NangYang
    Posts
    20
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default

    I dont get what you mean by "not work in php", can state what did u actually do? Because I think html and php can combine .

  8. #7
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by bowser View Post
    this is the code for the whole page:
    Code:
     . . . type="text/css" href="./css/chromestyle.css" />
    <script type="text/javascript" src="autoTab.js"></script>
    
    <script type="text/javascript" src="chrome.js"></script>
    <style type="text/css">
    <!--
    .style2 {color: #FFFFFF}
    -->
    </style>
    <script type="tex . . .
    Your page is in violation of Dynamic Drive's usage terms, which, among other things, state that the script credit must appear in the source code of the page(s) using the script. Please reinstate the notice first.


    For example:

    Code:
    <script type="text/javascript" src="chrome.js">
    
    /***********************************************
    * Chrome CSS Drop Down Menu- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
    * This notice MUST stay intact for legal use
    * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
    ***********************************************/
    
    </script>
    To answer your question perhaps - I don't see any PHP code in the menu. If you were to make a copy of that as an ordinary .html page and remove all of the PHP code from it, and place that new page in the same folder, it probably still wouldn't work. Which might mean that the path to the script is incorrect, and/or that there is some other ordinary error with the javascript and/or the markup for this script on your page.

    Like, if you are working from the distribution archive, the path to the script is:

    chromejs/chrome.js
    not:

    chrome.js
    as listed in your source code.

    Note: If your page is an include, it should use the absolute paths to its resources (like script, css, and image files).
    Last edited by jscheuer1; 07-23-2010 at 02:54 PM. Reason: Had a thought about the problem
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •