Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <select name="acabados[]">
- <option value="1">ABC</option>
- <option value="2">DEF</option>
- <option value="3">GHI</option>
- </select>
- <select name="acabados[]">
- <option value="1">ABC</option>
- <option value="2">DEF</option>
- <option value="3">GHI</option>
- </select>
- $(function () {
- var $select = $('select');
- $select.on('change', function () {
- var output = 0;
- for (var i = 0, len = $select.length; i < len; i++) {
- output += parseInt($select.eq(i).val());
- }
- //the `output` variable now contains the addition of all the values from the `acabados[]` select elements
- });
- });
- $(document).on('change', 'select[name="acabados[]"]', function(){
- var total = 0;
- $('select[name="acabados[]"]').each(function(){
- total += parseInt($(this).val());
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment