Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Javascript Dropdown Menu

Posted on 2007-10-21
10
Medium Priority
?
297 Views
Last Modified: 2008-01-09
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
0
Comment
Question by:mhoggatt1
  • 5
  • 4
10 Comments
 

Author Comment

by:mhoggatt1
ID: 20118722
Should be loads Makes and changes to Models.
0
 
LVL 29

Expert Comment

by:chilternPC
ID: 20118735
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.
0
 
LVL 82

Expert Comment

by:hielo
ID: 20118786
by menu you mean a selection list?
Do you want an AJAX solution?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:mhoggatt1
ID: 20118905
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>
0
 
LVL 82

Expert Comment

by:hielo
ID: 20119004
Try changing:
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
to
eval(top.location='"+selObj.options[selObj.selectedIndex].value+"'");
0
 
LVL 82

Expert Comment

by:hielo
ID: 20119011
Better yet, change
onChange="jumpMenu('parent.mainFrame',this,0)"
to
onChange="jumpMenu('top',this,0)"
0
 
LVL 82

Accepted Solution

by:
hielo earned 2000 total points
ID: 20119024
Slight change made to your jumpMenu function. The complete code is as follows:

<!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){
if(selObj.selectedIndex>0)
  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('top',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>
0
 

Author Comment

by:mhoggatt1
ID: 20119219
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
0
 

Author Comment

by:mhoggatt1
ID: 20119248
I posted the same thing at this address -
http://www.experts-exchange.com/Programming/Languages/Java/New_to_Java/Q_22905510.html

Which han't been replied to. Just post your rewrite to this one and I'll give you another 500 poins !
0
 
LVL 82

Expert Comment

by:hielo
ID: 20119423
Thank you very much. You are now in my "preferred customer" list
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question