Good morning!
I know this topic has been addressed on SO before, but I could not find a complete answer to my specific situation below, so I apologize if I missed the answer elsewhere.
Application area:
What I'm trying to achieve is a drop-down list (either made using pure HTML or a java script and HTML) that can load a php file. Inside this php file, it must have access to the selected dropdown value.
What I tried:
Method 1:
I used this method before:
<form action="test.php" method="post"> <select name="dropdown" id="dropdown"> <option value="value1">Option 1</option> <option value="value2">Option 2</option> </select> <input name="submitbutton" type="submit" value="submit" /> </form>
Then, by clicking the submit button, the test.php page loads, and I can get the value of the drop-down list using $ _POST ("dropdown"). This method works great! However, I want to submit the form WITHOUT the need for a button, just using the onchange dropdown event.
Method 2:
I also tried using:
<form> <select name='dropdown' onchange='this.form.submit()'> <option value="value1">Option 1</option> <option value="value2">Option 2</option> </select> <noscript><input type="submit" value="Submit"></noscript> </form>
which will reload the sharing page, but not the test.php page. Changing "this.form.submit ()" to test.php does not work.
I feel close to them, but not quite there. I hope that what I am trying to achieve is explained quite well.
Thanks for any answers ahead of time!
source share