PHP - How to submit a select menu without a button

forms, javascript

Solution

This is more appropriately tagged 'javascript' since it's javascript that you'll use to do it.

Add an 'onchange' event to the select. In the example below, 'form' should be substituted for your favourite method of targeting the form node.

<select name="something" class="something" title="something something" onchange="form.submit()">
<option selected="selected">Option One</option>
  <option >Option Two</option>
</select>

Problem

Is it possible to auto submit a select menu when the selection changes without using a button to submit the form. I have four of these on my page and using a button for each uses up too much space. By Select Menu, I mean: ``` <select name="something" class="something" title="something something"> <option selected="selected">Option One</option> <option >Option Two</option> </select> ``` I would also like to add a confirm popup for the on change event. The following is what I use for buttons but it does not work for the select menu. ``` onclick="return confirm('do you haz teh codz?');" ``` Any link to articles tutorials or examples would be greatly appreciated! Thanks

Original source