Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-08-2008, 12:30 PM   PM User | #1
bjblackmore
New Coder

 
Join Date: Dec 2008
Posts: 34
Thanks: 5
Thanked 0 Times in 0 Posts
bjblackmore is an unknown quantity at this point
Question Popup Message When Specific Option Selected

Hi,

I have a dropdown box with a few options that can be selected. Is it possible to have a popup message when just a specific option is selected?

I.e. in the select list below, people can select low or medium without getting a warning, but if they select High, a popup warning appears?
<script>
function popup () {
alert(\'Only select high prority if this is currently stopping you from working\');
}
</script>

<select name="level">
<option value="low">Low</option>
<option value="medium">Medium</option>
<option value="high" onClick="popup()">High</option>
</select>

Many thanks

Ben
bjblackmore is offline   Reply With Quote
Old 12-08-2008, 01:26 PM   PM User | #2
rangana
Senior Coder

 
rangana's Avatar
 
Join Date: Feb 2008
Location: Cebu City, Philippines
Posts: 1,752
Thanks: 65
Thanked 372 Times in 365 Posts
rangana will become famous soon enoughrangana will become famous soon enough
This one is erroneous:
Code:
alert(\'Only select high prority if this is currently stopping you from working\');
You should remove highlighted.

If your intention is to alert the message with quotes on it, then you should add highlighted:
Code:
alert('\'Only select high prority if this is currently stopping you from working\'');
Alternatively, you might find another way to skin a cat:
Code:
<script type="text/javascript">
function popup (el)
{
if(el.value.toLowerCase()=='high')
	alert('\'Only select high prority if this is currently stopping you from working\'');
}
</script>

<select name="level" onchange="popup(this)">
<option value="low">Low</option>
<option value="medium">Medium</option>
<option value="high">High</option>
</select>
Hope that helps.
__________________
Learn how to javascript at 02geek

The more you learn, the more you'll realize there's much more to learn
Ray.ph
rangana is offline   Reply With Quote
Users who have thanked rangana for this post:
bjblackmore (12-08-2008)
Old 12-08-2008, 02:16 PM   PM User | #3
bjblackmore
New Coder

 
Join Date: Dec 2008
Posts: 34
Thanks: 5
Thanked 0 Times in 0 Posts
bjblackmore is an unknown quantity at this point
Thumbs up

Hi rangana,

Thanks for the reply.

That seems to have done the trick.

Ref the backslashes, that was a posting error. I'm programming Java/HTML inside a PHP page, and needed to use the backslash to cancel out the single quote in the javascript. I forgot to remove it when I copy & pasted the code.

Thanks again

Ben
bjblackmore is offline   Reply With Quote
Reply

Bookmarks

Tags
option, popup, select

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:52 PM.


Advertisement
Log in to turn off these ads.