Advertisement
ganryu

Untitled

Aug 14th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function additem(chk, id, val)
  2. {
  3.     $("input[name='categoria[]']").each(function (index, element) { element.remove(); });
  4.  
  5.     $('input[type="checkbox"]:checked').each(function(index, element) {
  6.         var id = element.id;
  7.         var value = element.id.split('_')[1];
  8.         var newinput = '<input type="hidden" name="categoria[]" id="' + id + '" value="' + value + '">';
  9.         console.log(newinput);
  10.         $("#form_categorias").append(newinput);
  11.     });
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement