/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Drop down link in New Window

I have a drop down menu, and when the user clicks ‘go’, it jumps to the corresponding page (code below). Does anyone know how I can get this to open in a new window? (This should be pretty simple – but I’m terrible at JS)… Thanks a lot for any help.

[code]<script type=”text/javascript”>
<!–
function dropdown(mySel)
{
var myWin, myVal;
myVal = mySel.options[mySel.selectedIndex].value;
if(myVal)
{
if(mySel.form.target)myWin = parent[mySel.form.target];
else myWin = window;
if (! myWin) return true;
myWin.location = myVal;
}
return false;
}
//–>
</script>[/code]

[code=html]<form action=”../cgi-bin/redirect.pl” method=”post” onsubmit=”return dropdown(this.gourl)”>
<select name=”gourl”>
<option selected>choose a destination…
<option value=”http://www.htmlgoodies.com”>guide to html
<option value=”http://www.foremostgroups.com”>my home page
<option value=”http://www.ninthwonder.com”>ninth wonder
</select>
<input type=submit value=”go”>
</form>[/code]

and is this necessary (I obviously got this code from a website that provides scripts)… action=”../cgi-bin/redirect.pl”… i don’t even have that perl file, so this is useless, right?

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@dtm32236authorJan 03.2008 — nevermind - i got it...

&lt;form method="post"&gt;
&lt;p&gt;
&lt;select name="toilet_instruction_sheets"&gt;
&lt;option selected value=""&gt;Toilets
&lt;option value=""&gt;-----------------------------------
&lt;option value="downloads/instructions_AIO250-800.pdf"&gt;All-in-One 250-800
&lt;option value="downloads/instructions_AIO1000.pdf"&gt;All-in-One 1000
&lt;/select&gt;
&lt;input type="button" value="view" onclick="ob=this.form.toilet_instruction_sheets;window.open(ob.options[ob.selectedIndex].value)"&gt;
&lt;/p&gt;
&lt;/form&gt;
×

Success!

Help @dtm32236 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...