Get values from multiple select boxes with same name? Including its value with jquery and php

前端 未结 4 1278
伪装坚强ぢ
伪装坚强ぢ 2020-12-19 11:36

I have looked for answers on here and have not found anything that directly can help me so I am going to ask here. I have a form with multiple select boxes:

         


        
4条回答
  •  萌比男神i
    2020-12-19 11:57

    Try this, it will work for dynamically created select elements too.

    $(document).on('change', 'select[name="acabados[]"]', function(){
        var total = 0;
        $('select[name="acabados[]"]').each(function(){
            total += parseInt($(this).val());
        });
    });
    

    total var will contain the total of all the select elements selected value.

提交回复
热议问题