• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 10:48
CET 16:48
KST 00:48
  • 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
RSL Revival - 2025 Season Finals Preview8RSL Season 3 - Playoffs Preview0RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12
Community News
ComeBackTV's documentary on Byun's Career !3Weekly Cups (Dec 8-14): MaxPax, Clem, Cure win3Weekly Cups (Dec 1-7): Clem doubles, Solar gets over the hump1Weekly Cups (Nov 24-30): MaxPax, Clem, herO win2BGE Stara Zagora 2026 announced15
StarCraft 2
General
Did they add GM to 2v2? Weekly Cups (Dec 8-14): MaxPax, Clem, Cure win ComeBackTV's documentary on Byun's Career ! RSL Revival - 2025 Season Finals Preview Weekly Cups (Dec 1-7): Clem doubles, Solar gets over the hump
Tourneys
RSL Offline Finals Info - Dec 13 and 14! Master Swan Open (Global Bronze-Master 2) Winter Warp Gate Amateur Showdown #1: Sparkling Tuna Cup - Weekly Open Tournament $5,000+ WardiTV 2025 Championship
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 504 Retribution Mutation # 503 Fowl Play Mutation # 502 Negative Reinforcement Mutation # 501 Price of Progress
Brood War
General
FlaSh on: Biggest Problem With SnOw's Playstyle How Rain Became ProGamer in Just 3 Months BGH Auto Balance -> http://bghmmr.eu/ [BSL21] RO8 Bracket & Prediction Contest BW General Discussion
Tourneys
[Megathread] Daily Proleagues [BSL21] WB SEMIFINALS - Saturday 21:00 CET [BSL21] RO8 - Day 2 - Sunday 21:00 CET [ASL20] Grand Finals
Strategy
Game Theory for Starcraft Current Meta Simple Questions, Simple Answers Fighting Spirit mining rates
Other Games
General Games
Nintendo Switch Thread Stormgate/Frost Giant Megathread Path of Exile General RTS Discussion Thread Dawn of War IV
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
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Mafia Game Mode Feedback/Ideas Survivor II: The Amazon Sengoku Mafia TL Mafia Community Thread
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine The Games Industry And ATVI Russo-Ukrainian War Thread YouTube Thread
Fan Clubs
White-Ra Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece Movie Discussion!
Sports
2024 - 2026 Football Thread Formula 1 Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
TL+ Announced Where to ask questions and add stream?
Blogs
The (Hidden) Drug Problem in…
TrAiDoS
I decided to write a webnov…
DjKniteX
James Bond movies ranking - pa…
Topin
Thanks for the RSL
Hildegard
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2253 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
WardiTV 2025
13:00
Playoffs
herO vs SpiritLIVE!
Scarlett vs Gerald
Rogue vs Shameless
MaNa vs ShoWTimE
Nice vs Creator
WardiTV1489
ComeBackTV 711
TaKeTV 391
IndyStarCraft 241
Rex133
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Lowko450
Hui .262
IndyStarCraft 241
Rex 133
ProTech81
BRAT_OK 66
DivinesiaTV 15
StarCraft: Brood War
Britney 30554
Sea 3326
Calm 2543
Mini 1017
Larva 942
EffOrt 927
Horang2 894
ZerO 489
Soma 474
GuemChi 390
[ Show more ]
Snow 350
Stork 312
firebathero 304
Rush 213
Sharp 194
hero 154
PianO 104
Hyun 81
JYJ 57
Mind 45
Light 43
Pusan 40
sorry 39
Sea.KH 38
Mong 33
soO 29
Aegong 29
Killer 27
Movie 25
Terrorterran 22
scan(afreeca) 17
Shine 10
Dota 2
Gorgc5864
singsing4294
qojqva3114
Dendi1108
syndereN334
Counter-Strike
byalli1341
oskar154
markeloff125
Other Games
B2W.Neo1421
Beastyqt618
crisheroes353
mouzStarbuck168
QueenE91
Livibee77
Mew2King54
DeMusliM42
Trikslyr30
ZerO(Twitch)20
nookyyy 14
Organizations
StarCraft: Brood War
lovetv 5
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• HerbMon 17
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• WagamamaTV589
League of Legends
• Nemesis2487
• TFBlade754
Upcoming Events
WardiTV 2025
19h 12m
ByuN vs TBD
Clem vs TBD
OSC
22h 12m
CranKy Ducklings
1d 18h
WardiTV 2025
1d 19h
SC Evo League
1d 20h
Ladder Legends
2 days
BSL 21
2 days
Sziky vs Dewalt
eOnzErG vs Cross
Sparkling Tuna Cup
2 days
Ladder Legends
3 days
BSL 21
3 days
StRyKeR vs TBD
Bonyth vs TBD
[ Show More ]
Replay Cast
3 days
Wardi Open
3 days
Monday Night Weeklies
4 days
WardiTV Invitational
5 days
Replay Cast
6 days
WardiTV Invitational
6 days
ByuN vs Solar
Clem vs Classic
Cure vs herO
Reynor vs MaxPax
Liquipedia Results

Completed

Acropolis #4 - TS3
RSL Offline Finals
Kuram Kup

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
YSL S2
BSL Season 21
Slon Tour Season 2
CSL Season 19: Qualifier 1
WardiTV 2025
META Madness #9
eXTREMESLAND 2025
SL Budapest Major 2025
ESL Impact League Season 8
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22

Upcoming

CSL Season 19: Qualifier 2
CSL 2025 WINTER (S19)
BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
Big Gabe Cup #3
OSC Championship Season 13
ESL Pro League Season 23
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
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.