So I have a simple HTML select box, and a javascript alert function. I want the select box to have an onchange event that will call the javascript alert function. This is what I have so far:
HTML
<div style="float: left">Type: <select id="selector" onChange="jsfunction()">
<option value="Pyr">Pyramidally</option>
<option value="Lin">In-Lines</option>
<option value="Sym">Symmetrically</option>
<option value="Nsym">Non-Symmetrically</option>
</select>
</div>
Javascript
function jsfunction(){
alert("hi");
}
It doesn't work and for the life of me I can't figure out why. Most other questions of this nature I've found suggest ""
around calling the function - which I've got or making the onChange
'c' capital, which I also have. Any possible help? I'd be very grateful.
<!DOCTYPE html>
<html>
<head>
<script>
function jsfunction(){
alert("hi");
}
</script>
</head>
<body>
<select id="selector" onchange="jsfunction()">
<option value="Pyr">Pyramidally</option>
<option value="Lin">In-Lines</option>
<option value="Sym">Symmetrically</option>
<option value="Nsym">Non-Symmetrically</option>
</select>
</body>
</html>
It works. You made a mistake in onchange
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With