Calling javascript function from a select onChange

html, javascript, onchange

Solution

<!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`.

Problem

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.

Original source

Related problems