Guest User

Untitled

a guest
May 18th, 2013
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. <select name="acabados[]">
  2. <option value="1">ABC</option>
  3. <option value="2">DEF</option>
  4. <option value="3">GHI</option>
  5. </select>
  6.  
  7. <select name="acabados[]">
  8. <option value="1">ABC</option>
  9. <option value="2">DEF</option>
  10. <option value="3">GHI</option>
  11. </select>
  12.  
  13. $(function () {
  14. var $select = $('select');
  15. $select.on('change', function () {
  16. var output = 0;
  17. for (var i = 0, len = $select.length; i < len; i++) {
  18. output += parseInt($select.eq(i).val());
  19. }
  20. //the `output` variable now contains the addition of all the values from the `acabados[]` select elements
  21. });
  22. });
  23.  
  24. $(document).on('change', 'select[name="acabados[]"]', function(){
  25. var total = 0;
  26. $('select[name="acabados[]"]').each(function(){
  27. total += parseInt($(this).val());
  28. });
  29. });
Advertisement
Add Comment
Please, Sign In to add comment