HTML Help Forum Index HTML Help
Please Search for the answer to your question before asking it! Thanks.
 

Dropdown menus
Post a Reply to this Topic Ask a New Question
Click here to go to the original topic
       HTML Help Forum Index -> Javascript
View previous topic :: View next topic  
Author Message
lpattison



Joined: 01 Jun 2009
Posts: 3

Posted: Mon Jun 01, 2009 7:05 pm     Dropdown menus  

I appologize, as I know nothing about Javascript. I found this script on this site which works great, but I need the links to open in a new window/tab.

I need it as simple as possible please. Here is the code.

<SCRIPT TYPE="text/javascript">
<!--
function dropdown(mySel)
{
var myWin, myVal;
myVal = mySel.options[mySel.selectedIndex].value;
if(myVal)
{
if(mySel.form.target)myWin = window.open[mySel.form.target];
else myWin = window;
if (! myWin) return true;
myWin.location = myVal;
}
return false;
}
//-->
</SCRIPT>

and the code in the <body> is:

<FORM
ACTION="../cgi-bin/redirect.pl"
METHOD=POST onSubmit="return dropdown(this.gourl)">
<SELECT NAME="gourl">
<option value="">Go to (browse sites)
<OPTION VALUE="site 1" >Site 1
<OPTION VALUE="site 1" >Site 2
<OPTION VALUE="site 3" >Site 3
</SELECT>

<INPUT TYPE=SUBMIT VALUE="Go">
</FORM>

Thank you very much for your time.
PayneLess Designs



Joined: 28 Feb 2007
Posts: 3593
Location: Biloxi, MS

Posted: Tue Jun 02, 2009 1:50 am      

Between head tags: Code: <script type="text/JavaScript">
function MM_jumpMenu(targ,selObj,restore){ //v3.0
var s = selObj.options[selObj.selectedIndex].value;
window.open(s);
if (restore) selObj.selectedIndex=0;
}
</script>

Between body tags: Code: <form name="form1" action="null">
<select name="menu1" onChange="MM_jumpMenu('parent',this,0)">
<option selected>-- select --</option>
<option value="http://google.com">Google</option>
<option value="http://answers.yahoo.com/">Yahoo!Answers</option>
</select>
</form>

Add URLs as needed.
lpattison



Joined: 01 Jun 2009
Posts: 3

Posted: Thu Jun 04, 2009 8:05 am      

Thank you so much Ron. Your assistance is very much appreciated.
lpattison



Joined: 01 Jun 2009
Posts: 3

Posted: Thu Jun 04, 2009 8:13 am      

As well, what I like about the code you sent back, is that it omits the GO button. Definitely not required.

Thanks again.
PayneLess Designs



Joined: 28 Feb 2007
Posts: 3593
Location: Biloxi, MS

Posted: Thu Jun 04, 2009 7:39 pm      

You're very welcome. Yeh, I never like that Go button much. :P
 
 
DARFUR
HOSTING / DESIGN
MAKE MONEY

       HTML Help Forum Index -> Javascript
Page 1 of 1


Powered by phpBB Search Engine Indexer
Powered by phpBB 2.0.19 © 2001, 2002 phpBB Group