/    Sign up×
Community /Pin to ProfileBookmark

Pulldown Menu (Popup) – with static values

Hi,

I am using this code from the site:

[CODE]<SCRIPT LANGUAGE=”JavaScript”>

<!– This script and many more are available free online at –>
<!– The JavaScript Source!! http://javascript.internet.com –>

<!– Begin
function formHandler(form) {
var windowprops = “height=500,width=500,location=no,”
+ “scrollbars=no,menubars=no,toolbars=no,resizable=yes”;

var URL = form.site.options[form.site.selectedIndex].value;
popup = window.open(URL,”MenuPopup”,windowprops);
}
// End –>
</script>
</HEAD>

<!– STEP TWO: Copy this code into the BODY of your HTML document –>

<BODY>

<center>
<form name=form>
<select name=site SIZE=1 onChange=”formHandler(this.form)”>
<option value=”http://www.yoursite.com”>Go to….
<option value=”http://www.yahoo.com”>Yahoo
<option value=”http://www.metacrawler.com”>Metacrawler
<option value=”http://www.altavista.digital.com”>Altavista
<option value=”http://www.webcrawler.com”>Webcrawler
<option value=”http://www.lycos.com”>Lycos
<option value=”http://javascript.internet.com”>JavaScript Source
</select>
</form>
</center>[/CODE]

What I am trying to acheive is for only one value to work as a link, and the rest as normal static values.

Is this possible with this code? Or will I have to try something new?

Thanks

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@blah1985Dec 12.2005 — hmm add an if value like of if(form=='whateverUrlIsALink')

{

//condition here

}
Copy linkTweet thisAlerts:
@foolishtigerauthorDec 12.2005 — Okay I've got this:

[CODE]function doBlah(s, i) {
if (s.selectedIndex == i) {
window.location = s.options[i].value;
}
}[/CODE]


But I really need for the link to appear in a new window. Anyone know how I can do this?
Copy linkTweet thisAlerts:
@blah1985Dec 12.2005 — use window.open()
Copy linkTweet thisAlerts:
@foolishtigerauthorDec 12.2005 — use window.open()[/QUOTE]

Thanks,

not quite sure exactly where to put it though (please excuse I'm a newbie when it comes to javascripts).

I have tried:

[CODE]function doBlah(s, i) {
if
(s.selectedIndex == i) {
window.location = s.options[i].value;
window.open()
}
}[/CODE]


What happens is: it opens a new blank window then the link appears in the main window.

Where do I put it so the link is in the new window?

thanks
Copy linkTweet thisAlerts:
@foolishtigerauthorDec 13.2005 — Got it ?:

[CODE]<SCRIPT LANGUAGE="JavaScript">
function doBlah(s, i) {
if
(s.selectedIndex == i) {
window.open(s.options[i].value)
}
}
</SCRIPT>[/CODE]


cheers
Copy linkTweet thisAlerts:
@KingKoenDec 13.2005 — I guess you can do something like this:

[CODE]<!-- Begin
var popup;
var POPUP_INDEX = 1

function formHandler(form) {
if (form.site.selectedIndex == POPUP_INDEX) {
// This one should be opened in a seperated window
var windowprops = "height=500,width=500,location=no,scrollbars=no,menubars=no,toolbars=no,resizable=yes";
var url = form.site.options[form.site.selectedIndex].value;
popup = window.open(url, "MenuPopup", windowprops);
popup.focus();
}
}
// End -->
</script>
</HEAD>[/CODE]


Could be that I made some typos somewhere, but I think this is what you asked for.
×

Success!

Help @foolishtiger 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 6.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...