• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 02:12
CEST 08:12
KST 15:12
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
HomeStory Cup 27 - Info & Preview18Classic wins Code S Season 2 (2025)16Code S RO4 & Finals Preview: herO, Rogue, Classic, GuMiho0TL Team Map Contest #5: Presented by Monster Energy6Code S RO8 Preview: herO, Zoun, Bunny, Classic7
Community News
Flash Announces Retirement From ASL7Weekly Cups (June 23-29): Reynor in world title form?12FEL Cracov 2025 (July 27) - $8000 live event16Esports World Cup 2025 - Final Player Roster14Weekly Cups (June 16-22): Clem strikes back1
StarCraft 2
General
Weekly Cups (June 23-29): Reynor in world title form? StarCraft Mass Recall: SC1 campaigns on SC2 thread The SCII GOAT: A statistical Evaluation How does the number of casters affect your enjoyment of esports? Esports World Cup 2025 - Final Player Roster
Tourneys
FEL Cracov 2025 (July 27) - $8000 live event HomeStory Cup 27 (June 27-29) WardiTV Mondays SOOPer7s Showmatches 2025 $200 Biweekly - StarCraft Evolution League #1
Strategy
How did i lose this ZvP, whats the proper response Simple Questions Simple Answers [G] Darkgrid Layout
Custom Maps
[UMS] Zillion Zerglings
External Content
Mutation # 480 Moths to the Flame Mutation # 479 Worn Out Welcome Mutation # 478 Instant Karma Mutation # 477 Slow and Steady
Brood War
General
Flash Announces Retirement From ASL ASL20 Preliminary Maps BW General Discussion BGH Auto Balance -> http://bghmmr.eu/ StarCraft & BroodWar Campaign Speedrun Quest
Tourneys
[Megathread] Daily Proleagues [BSL20] GosuLeague RO16 - Tue & Wed 20:00+CET The Casual Games of the Week Thread [BSL20] ProLeague LB Final - Saturday 20:00 CET
Strategy
Simple Questions, Simple Answers I am doing this better than progamers do.
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread Path of Exile What do you want from future RTS games? Beyond All Reason
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
US Politics Mega-thread Trading/Investing Thread Things Aren’t Peaceful in Palestine Stop Killing Games - European Citizens Initiative Russo-Ukrainian War Thread
Fan Clubs
SKT1 Classic Fan Club! Maru Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece [\m/] Heavy Metal Thread Korean Music Discussion
Sports
2024 - 2025 Football Thread NBA General Discussion Formula 1 Discussion TeamLiquid Health and Fitness Initiative For 2023 NHL Playoffs 2024
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List
Blogs
from making sc maps to makin…
Husyelt
Blog #2
tankgirl
Game Sound vs. Music: The Im…
TrAiDoS
StarCraft improvement
iopq
Heero Yuy & the Tax…
KrillinFromwales
Trip to the Zoo
micronesia
Customize Sidebar...

Website Feedback

Closed Threads



Active: 529 users

Another Plea for Help...This time: Javascript

Blogs > Polemos
Post a Reply
Polemos
Profile Blog Joined March 2011
United States160 Posts
August 12 2011 16:17 GMT
#1
Okay - I have seriously struggled on this for about 10 hours. I have been trying a little bit of javascript, but not without it's issues.

I have a html dropdown menu: Select & options and what not. I have tried to put an onlick event with javascript to put make a popup when a certain element is clicked. This functions perfectly in Firefox & Opera, but not in Safari & Chrome. I have searched for hours with no luck, so I turn to you guys :[ Can anyone tell me WHY this isn't working.

Thank you so much !

+ Show Spoiler +


<!doctype html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="popup.css" />
<script type="text/javascript">
function myPopup3() {
window.open("http://dev.ieworks.net/devtest/location_add.html","myWindow"," status=1, height=300, width=300, resizable=0");
}
</script>
<script type="text/javascript">
<!--
document.getElementById("demo").innerHTML=Date();
//-->
</script>
</head>
<body>
<form>
<input type="button" onClick="myPopup3()" value="Click Meh!">
</form>
<!--<p onClick="myPopup2()">Click This^^^^!</p>-->
<form>
<select>
<option value="Select">Select an option</option>
<option value="----" disabled="disabled">----------------------</optgroup>
<option value="Click here!" onclick="myPopup3()">Click here!</option>
<option value="Hi there!">Hi there!</option>
</select>
</body>

Elements not working in Safari and Chrome are in bold.


Link to where website is up: dev.ieworks.net/devtest/popup.html

Thank you!!!


It is better to be hated for who you are then loved for who you are not.
SnowPet
Profile Joined August 2004
9 Posts
August 12 2011 16:33 GMT
#2
Might be because those browser have a better inbuilt popup blocker. The fact that it's working in my FF is an annoyance to me.
Polemos
Profile Blog Joined March 2011
United States160 Posts
August 12 2011 16:34 GMT
#3
._.

It works in Chrome if you press the button and don't use the drop-down menu to pop it open.
It is better to be hated for who you are then loved for who you are not.
Kr1pos
Profile Joined January 2008
Norway67 Posts
Last Edited: 2011-08-12 16:44:31
August 12 2011 16:41 GMT
#4
As you are experiencing, onClick() is not supported on the option-tag in many browsers. Instead you should use the "onChange()"-event for the select-tag and do whatever if a check shows the selected item is the one you want.

Edit: Also, I don't understand how you didn't find this out by searching. Almost every hit on the first page from a Google-search for "javascript option onclick" seems to be about this.
Polemos
Profile Blog Joined March 2011
United States160 Posts
August 12 2011 16:44 GMT
#5
so - How do I have to change

<option value="Click here!" onChange="myPopup3()">Click here!</option>

?
It is better to be hated for who you are then loved for who you are not.
Kr1pos
Profile Joined January 2008
Norway67 Posts
August 12 2011 16:57 GMT
#6
Here's an example using onChange() (adapted from the first hit on Google for the search mentioned above):
+ Show Spoiler +
<script type="text/javascript">
function changeFunc(valueSelected) {
if(valueSelected == "Click here!") alert("You selected \'Click here!\'");
else alert("You selected something else");
}
</script>

<select onchange="changeFunc(this.value);">
<option value="Select">Select an option</option>
<option value="Click here!">Click here!</option>
<option value="Hi there!">Hi there!</option>
</select>
Polemos
Profile Blog Joined March 2011
United States160 Posts
August 12 2011 17:12 GMT
#7
I'm sorry - I'm having a lot of problems following that. I don't see how to make it work.
It is better to be hated for who you are then loved for who you are not.
Kr1pos
Profile Joined January 2008
Norway67 Posts
Last Edited: 2011-08-12 17:33:24
August 12 2011 17:32 GMT
#8
I'm no Javascript-expert, but I can try a quick explanation

<select onchange="changeFunc(this.value);">
This means, when what's selected in the combo-box changes, the function named "changeFunc" is called. Passed on to the function is the value of the selected item (in "this.value", this refers to the <option> selected, so we're passing on the <option>'s value).

For example, if you have an selectable item defined by <option value="item1">Something</option> and selects it, the function changeFunc is called with "item1" as the argument.

function changeFunc(valueSelected) {
if(valueSelected == "Click here!") alert("You selected \'Click here!\'");
else alert("You selected something else");
}
This defines the function which is called when the selection changes. In it, I check if the passed argument (named valueSelected) is something I'm looking for. The function checks if the value is equal to "Click here!", and depending on if it is or not it display different messages.

In your case you don't want to display a message but rather open a window, so you'd change it to:
+ Show Spoiler +
if(valueSelected == "Click here!") window.open("http://dev.ieworks.net/devtest/location_add.html","myWindow"," status=1, height=300, width=300, resizable=0");

That way, even though the function is called on every change in the combo-box, a new window is only opened when the change is that the item with value "Click here!" was selected.

Hopefully that helps
Please log in or register to reply.
Live Events Refresh
Next event in 9h 48m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
trigger 16
StarCraft: Brood War
Britney 20888
Noble 20
Aegong 14
ajuk12(nOOB) 6
Bale 2
Dota 2
monkeys_forever640
League of Legends
JimRising 702
Counter-Strike
summit1g7448
Stewie2K860
Super Smash Bros
Mew2King163
Heroes of the Storm
Khaldor96
Other Games
shahzam759
WinterStarcraft369
Organizations
Other Games
gamesdonequick936
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 16 non-featured ]
StarCraft 2
• practicex 68
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• Azhi_Dahaki58
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• lizZardDota271
League of Legends
• Lourlo1015
• masondota2386
• Stunt331
Upcoming Events
uThermal 2v2 Circuit
9h 48m
Replay Cast
17h 48m
The PondCast
1d 3h
RSL Revival
1d 3h
ByuN vs Classic
Clem vs Cham
WardiTV European League
1d 9h
Replay Cast
1d 17h
RSL Revival
2 days
herO vs SHIN
Reynor vs Cure
WardiTV European League
2 days
FEL
2 days
Korean StarCraft League
2 days
[ Show More ]
CranKy Ducklings
3 days
RSL Revival
3 days
FEL
3 days
Sparkling Tuna Cup
4 days
RSL Revival
4 days
FEL
4 days
BSL: ProLeague
4 days
Dewalt vs Bonyth
Replay Cast
5 days
Replay Cast
6 days
Liquipedia Results

Completed

Proleague 2025-06-28
HSC XXVII
Heroes 10 EU

Ongoing

JPL Season 2
BSL 2v2 Season 3
BSL Season 20
Acropolis #3
KCM Race Survival 2025 Season 2
CSL 17: 2025 SUMMER
Copa Latinoamericana 4
Championship of Russia 2025
RSL Revival: Season 1
Murky Cup #2
BLAST.tv Austin Major 2025
ESL Impact League Season 7
IEM Dallas 2025
PGL Astana 2025
Asian Champions League '25
BLAST Rivals Spring 2025
MESA Nomadic Masters
CCT Season 2 Global Finals
IEM Melbourne 2025
YaLLa Compass Qatar 2025

Upcoming

CSLPRO Last Chance 2025
CSLPRO Chat StarLAN 3
K-Championship
uThermal 2v2 Main Event
SEL Season 2 Championship
FEL Cracov 2025
Esports World Cup 2025
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.