简体   繁体   中英

how to get the values from add remove selection box

I have two multiple selection box for caste and sub-caste. Add / Remove button used in both the selection box. I want to filter sub-caste based on caste. how can i get the value of caste selection box. I'm using the code for Add / Remove is

$('#btn-add').click(function(){
    $('#caste option:selected').each( function() {
        $('#caste_new').append("<option value='"+$(this).val()+"'>"+$(this).text()+"</option>");
        $(this).remove();
    });
});
$('#btn-remove').click(function(){
    $('#caste_new option:selected').each( function() {
        $('#caste').append("<option value='"+$(this).val()+"'>"+$(this).text()+"</option>");
        $(this).remove();
    });
}); 

and also using ajax for fetch the values from database. Please help. Thanks in advance.

$("#caste :input"); 

Should select all inputs that have been appended. After that you just need to go over the list and fetch value

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