Reputation: 1467
I am looking for a way to submit my form when I click a <option>
.
Explanation of <select>
use:
Click checkboxes and then choose what folder to move the ones that were selected to using the drop-down menu.
Here is what my form looks like: http://jsfiddle.net/Draven/yufwu/23/
Keep in mind the checkboxes have multiple uses (delete, move to folder).
And the drop-down menu (<select>
) is retrieving the folders from the folders
table.
I am having a hard time explaining this so if you have any questions just ask.
EDIT: Thanks to NullPointer I got this working. Exact code below.
<script type="text/javascript">
//<![CDATA[
$(document).ready(function(){
$('select').change(function ()
{
$(this).closest('form[name="delete-volunteer-app"]').submit();
});
});//]]>
</script>
Upvotes: 0
Views: 1876
Reputation: 56
$(document).ready(function(){
$('#select').change(function(){
var select_val = $(this).val();
// make ajax hit for select value
})
})
just submit the form or it is better to send ajax hit according to your requirement
Upvotes: 0
Reputation: 178421
Plain JS:
window.onload=function() {
document.getElementsByName("folder")[0].onchange=function() {
this.form.submit();
}
}
Upvotes: 0
Reputation: 57342
try
$('option').click(function () //ill sugest to use the change event
{
$(this).closest('form').submit(); //or $("form id or class or form[name="formname"]").submit();
});
Upvotes: 3