Whing Dela Cruz
asked on
Do alert on select
Hi experts, I wish to have an alert in every time i do select. As the code shown below.. Thanks!
<!DOCTYPE html>
<html>
<body>
<form>
<select name="cars">
<option value="volvo">Volvo</optio n>
<option value="saab">Saab</option>
<option value="fiat" selected>Fiat</option>
<option value="audi">Audi</option>
</select>
</form>
<script>
function iSelect()
{
alert is here...
}
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<form>
<select name="cars">
<option value="volvo">Volvo</optio
<option value="saab">Saab</option>
<option value="fiat" selected>Fiat</option>
<option value="audi">Audi</option>
</select>
</form>
<script>
function iSelect()
{
alert is here...
}
</script>
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
I change the alert(x) to alert(x.value) and now its working. Thank you!
You're welcome!
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Thanks a lot both of you guys!
ASKER
<form>
<select name="cars" onchange="iSelect(this)";>
<option value="volvo">Volvo</optio
<option value="saab">Saab</option>
<option value="fiat" selected>Fiat</option>
<option value="audi">Audi</option>
</select>
</form>
<script>
function iSelect(x)
{
alert(x)
}
</script>