/    Sign up×
Community /Pin to ProfileBookmark

Alert message on select option

I have a form that I want to pop up an alert message is someone selects the letter “A” from my select menu. I tried all different stuff and cant get the alert message to pop up when “A” is selected. I tried :
if(document.myform.myvalue.value = “A”)

and it popped up alert message on all selections.

Here is the whole form part where I tried:

function check()
{

if(document.myform.myvalue.value == “A”)
{
alert(“Dont select the letter A”)
return false

}

<cfform name=”myform” action=”dosomething.cfm” onSubmit=”return check();”>

<select name=”myvalue” size=”1″>
<option value=”A” selected>A</option>
<option value=”b”>b</option>
<option value=”c”>c</option>

</select>

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@numba_oneJan 31.2003 — Heres sumthin i got for you.....this one is with ait what you want...

<form><input type="button" value="click here" onClick='alert("Your message here")'></form>
Copy linkTweet thisAlerts:
@WebskaterJan 31.2003 — function check()

{


if(document.myform.myvalue.options[myform.myvalue.selectedIndex].text == "A")

{

alert("Dont select the letter A")

return false

}

else

{

return true

}
Copy linkTweet thisAlerts:
@floridaauthorJan 31.2003 — Thanks!
×

Success!

Help @florida 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.16,
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,
)...