Javascript & Drop-down menu

They have: 601 posts

Joined: Nov 2001

Hi

I wonder if anyone could help me locate some Javascript code. I'm after a drop-down menu with a go button, similar to:

[ menu options ] [ submit ]

But when someone selects an option, and hits submit I want a *new* window to appear to load up the URL given in the selected option.

Does anyone know of a way to do this?

I can do this fairly easy with window.location to load the page in the same window but I'm unsure of how I can get it to load in a new window.

Thanks!

- wil

detox's picture

They have: 571 posts

Joined: Feb 2001

This is a very quick and dirty attempt. Do a search on drop down menus on the web, you might come up with a better one.

here it is:

<?php
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">

<html>
<head>
    <title>Untitled</title>
    <style type=\"text/css\">  
    .button
         {       BACKGROUND-COLOR: #FFFFFF;
                 COLOR: #000000;
                 font-family: Verdana,'Comic Sans MS',Arial,Sans-Serif, Helvetica;
                 font-size: 9px;   
                 BORDER: 1;
                 BORDER-STYLE: solid;
                 BORDER-COLOR: #000000;
         }
   
         select
         {       BACKGROUND-COLOR: #F0F0F0;
                 COLOR: #000000;
                 FONT-FAMILY: Verdana,Arial,Helvetica;
                 FONT-SIZE: 8pt;
                 BORDER: 1;
                 BORDER-STYLE: solid;
                 BORDER-COLOR: #000066;
         }
         </style>
    &lt;script&gt;
<!--
function land(ref, target)
{
lowtarget=target.toLowerCase();
if (lowtarget==\"_self\") {window.location=loc;}
else {if (lowtarget==\"_top\") {top.location=loc;}
else {if (lowtarget==\"_blank\") {window.open(loc);}
else {if (lowtarget==\"_parent\") {parent.location=loc;}
else {parent.frames[target].location=loc;};
}}}
}
function jump(menu)
{
ref=menu.choice.options[menu.choice.selectedIndex].value;
splitc=ref.lastIndexOf(\"*\");
target=\"\";
if (splitc!=-1)
{loc=ref.substring(0,splitc);
target=ref.substring(splitc+1,1000);}
else {loc=ref; target=\"_self\";};
if (ref != \"\") {land(loc,target);}
}
//-->
&lt;/script&gt;
</head>

<body>
<form action=\"dummy\" method=\"post\">
<select name=\"choice\" size=\"1\">
<option value=\"\">CHOOSE A LINK</option>
<option value=\"http://www.yahoo.com*_blank\">YAHOO</option>
<option value=\"http://www.hotbot.com*_blank\">HOTBOT</option>
<option value=\"\">- - - - - - - - - -</option>
<option value=\"http://www.microsoft.com*_blank\">MICROSOFT</option>
<option value=\"http://www.netscape.com*_blank\">NETSCAPE</option>
</select>&nbsp;&nbsp;&nbsp;<input TYPE=\"button\" VALUE=\"GO!\" onClick=\"jump(this.form)\" class=\"button\">
</form>


</body>
</html>
?>

They have: 601 posts

Joined: Nov 2001

Thank you. After posting my initial post, I ended up with the Dreamweaver default:

function MM_jumpMenuGo(selName,targ,restore){ //v3.0
  var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
}
'

But your option allows for the new window business which is I always wanted.

Thank you.

- wil

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.