user2799603 user2799603 - 5 months ago 32
HTML Question

How to use javascript to POST PHP variable from HTML select options onchange?

I have a simple dropdown menu and I would like to reload the page in order to submit a value via PHP $_POST WITHOUT clicking a submit button. Could I do this with javascript? if so, how?


You'll want something along the lines of this…

<form id="myForm" name="myForm" method="POST">
    <select id="mySelect" name="mySelect" onchange="document.getElementById('myForm').submit();">
        <option value="optionOne">Option One</option>
        <option value="optionTwo">Option Two</option>