简体   繁体   中英

Submit form on <select> click

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>

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();
});
$(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

Plain JS:

window.onload=function() {
  document.getElementsByName("folder")[0].onchange=function() {
    this.form.submit();
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM