Link to home
Start Free TrialLog in
Avatar of mhoggatt1
mhoggatt1

asked on

Javascript Dropdown Menu

I'm looking for the Javascript code that loads car makes into a dropdown menu and changes the page to Makes when a selection is made. I have one but I'm not sure it's what I'm looking for. I'll be loading it from a DB.

Thanks,
Michael
Avatar of mhoggatt1
mhoggatt1

ASKER

Should be loads Makes and changes to Models.
Avatar of Peter Hart
I assume you have abandon the other post on javasript menus?
I would use a javascript tools as mentioned www.likno.com they also provide an interface for dynamic menus from databases.
but I think you mean you want the menu to read fom the database? - actually what you want is a standard javasript menu to link to all the pages (likno or the free site I mentioned) and its the pagesget loaded  that then access the database to produce the page.
by menu you mean a selection list?
Do you want an AJAX solution?
Actually I have a routine Which I would like modified. It's a Javascript routine written for me a couple of years ago. It has a dropdown menu in the left frame that changes the right frame.
I don't know anything about JS. So I need this one modified or you could write a new one for me that does this -
When the selection is made it displays the page (no frames). In this case the variable action_name will be in the menu and it will link to directory_link which is a php page.

Here's my code -

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<Script language="JavaScript"><!--
function jumpMenu(targ,selObj,restore){
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
//--></Script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>bsd_select.php</title>
</head>
<body>
<form>
    Search the Database <br>
    <select style="width:125px" name="menu1" onChange="jumpMenu('parent.mainFrame',this,0)"><option>Make a Selection</option>
    <?php
      $include_path = "";
      require_once($include_path. 'uis.php');
      require_once($include_path. 'myconfig.php');

     $i=0;
     $j=0;

// $result = mysql_query("SELECT DISTINCT ministryID, ministry_name, ministry_link FROM ".$myconfig->dt['ministries']." ORDER BY ministry_name ASC") or die("Sql error : " . mysql_error());
$result = mysql_query("SELECT DISTINCT jz_directoryID, action_name, directory_link FROM ".$myconfig->dt['jz_directory']." ORDER BY action_name ASC") or die("Sql error : " . mysql_error());

while ($row = mysql_fetch_array($result)) {
echo "<option value=\"{$row['directory_link']}?id={$row['jz_directoryID']}\">".$row["action_name"]."</option>\n";
     }

?>
    </select>
</form>

<?php
?>
</body>
</html>
Try changing:
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
to
eval(top.location='"+selObj.options[selObj.selectedIndex].value+"'");
Better yet, change
onChange="jumpMenu('parent.mainFrame',this,0)"
to
onChange="jumpMenu('top',this,0)"
ASKER CERTIFIED SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Works great ! Thanks you very much for the rewrite. I increased the points to 500 for the expert service. Hope to do business with you again.

Michael
I posted the same thing at this address -
https://www.experts-exchange.com/questions/22905510/Java-code-modify.html

Which han't been replied to. Just post your rewrite to this one and I'll give you another 500 poins !
Thank you very much. You are now in my "preferred customer" list