user2799603 user2799603 - 1 year ago 98
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?

Answer Source

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>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download