1

I did a research and i didn't find solution. I am trying to submit a form using javascript method submit(). The code below shows what i am trying to do. This code works fine in firefox and IE, but in chrome and safari, the form does not submit. Can someone gives me an idea, what i am doing wrong. Thanks in advance !

<body>

    <form method="post" id="simpleForm">
        <select name="selectMenu" >
            <option id="1" value="1" onclick="ssform();">1</option>
            <option id="2" value="2" onclick="ssform();">2</option>
            <option id="3" value="3" onclick="ssform();">3</option>
        </select>
    </form>
    <script>
        function ssform() {
            document.getElementById("simpleForm").submit();
        }
    </script>

    <?php
        var_dump($_POST['selectMenu']);
    ?>
</body>

ManoDestra
  • 6,047
  • 6
  • 24
  • 50
tobarata
  • 58
  • 1
  • 7

1 Answers1

3

Event handlers attached to options does not work on every browser. Use the change event on the select.

<select name="selectMenu" onchange="ssform();">
epascarello
  • 195,511
  • 20
  • 184
  • 225