title: How to remove duplicate selected items and replace with quantity
body: <p>I have been working on this project for school. It is a supply list for grades K-J. Each grade has #2 pencils and various other similar items. When you select one item in Kindergarten (#2 pencils) and select the same item in say Fifth Grade, then generate the list I do not need #2 pencils to show up twice, but only once with a quantity number next to it.  </p>
  
  <p>I am sure it has something to do with an if statement, but I'm still trying to master those.</p>
  
  <p>Here is the jquery mobile part</p>
  
  <pre><code>&lt;body&gt;
  &lt;section class="header_default footer_default" data-role="page" id="setup" data-title="Setup"&gt;
  &lt;article data-role="content"&gt;
      &lt;div class="loaded"&gt;&lt;/div&gt;
      &lt;p id="count"&gt;&lt;/p&gt;
      &lt;form&gt;
  &lt;fieldset data-role="controlgroup" id="hoursName"&gt;
              &lt;legend&gt;&lt;strong&gt;Kindergarten Supply List:&lt;/strong&gt;&lt;/legend&gt;
              &lt;input type="checkbox" class="checkbox-group" name="checkboxsupply" id="1" value="(48 Quanity) #2 6-sided pencils (sharpened preferred)" &gt;
              &lt;label for="1"&gt;(48 Quanity) #2 6-sided pencils (sharpened preferred)&lt;/label&gt;
              &lt;input type="checkbox" class="checkbox-group" name="checkboxsupply" id="2" value="(2 Quanity) Red pencils"&gt;
              &lt;label for="2"&gt;(2 Quanity) Red Pencils&lt;/label&gt;
              &lt;input type="checkbox" class="checkbox-group" name="checkboxsupply" id="3" value="(1 Quanity) Pack of pink erasers"&gt;
              &lt;label for="3"&gt;(1 Quanity) Pack of pink erasers&lt;/label&gt;
              &lt;input type="checkbox" class="checkbox-group" name="checkboxsupply" id="4" value="(1 Quanity) Box of Kleenex (tissue)"&gt;
              &lt;label for="4"&gt;(1 Quanity) Box of Kleenex (tissue)&lt;/label&gt;
              &lt;input type="checkbox" class="checkbox-group" name="checkboxsupply" id="5" value="(1 Quanity) Pack of pencil cap erasers"&gt;
              &lt;label for="5"&gt;(1 Quanity) Pack of pencil cap erasers&lt;/label&gt;
          &lt;/fieldset&gt;
          &lt;fieldset data-role="controlgroup" id="hoursName"&gt;
              &lt;legend&gt;&lt;strong&gt;First Grade Supply List:&lt;/strong&gt;&lt;/legend&gt;
              &lt;input type="checkbox" name="checkboxsupply" id="1" value="(48 Quanity) #2 6-sided pencils (sharpened preferred)" &gt;
              &lt;label for="1"&gt;(48 Quanity) #2 6-sided pencils (sharpened preferred)&lt;/label&gt;
              &lt;input type="checkbox" name="checkboxsupply" id="2" value="(2 Quanity) Red pencils"&gt;
              &lt;label for="2"&gt;(2 Quanity) Red Pencils&lt;/label&gt;
              &lt;input type="checkbox" name="checkboxsupply" id="3" value="(1 Quanity) Pack of pink erasers"&gt;
              &lt;label for="3"&gt;(1 Quanity) Pack of pink erasers&lt;/label&gt;
              &lt;input type="checkbox" name="checkboxsupply" id="4" value="(1 Quanity) Box of Kleenex (tissue)"&gt;
              &lt;label for="4"&gt;(1 Quanity) Box of Kleenex (tissue)&lt;/label&gt;
              &lt;input type="checkbox" name="checkboxsupply" id="5" value="(1 Quanity) Pack of pencil cap erasers"&gt;
              &lt;label for="5"&gt;(1 Quanity) Pack of pencil cap erasers&lt;/label&gt;
          &lt;/fieldset&gt;
          &lt;fieldset data-role="controlgroup" id="hoursName"&gt;
              &lt;legend&gt;&lt;strong&gt;Second Grade Supply List:&lt;/strong&gt;&lt;/legend&gt;
              &lt;input type="checkbox" name="checkboxsupply" id="1" value="(48 Quanity) #2 6-sided pencils (sharpened preferred)" &gt;
              &lt;label for="1"&gt;(48 Quanity) #2 6-sided pencils (sharpened preferred)&lt;/label&gt;
              &lt;input type="checkbox" name="checkboxsupply" id="2" value="(2 Quanity) Red pencils"&gt;
              &lt;label for="2"&gt;(2 Quanity) Red Pencils&lt;/label&gt;
              &lt;input type="checkbox" name="checkboxsupply" id="3" value="(1 Quanity) Pack of pink erasers"&gt;
              &lt;label for="3"&gt;(1 Quanity) Pack of pink erasers&lt;/label&gt;
              &lt;input type="checkbox" name="checkboxsupply" id="4" value="(1 Quanity) Box of Kleenex (tissue)"&gt;
              &lt;label for="4"&gt;(1 Quanity) Box of Kleenex (tissue)&lt;/label&gt;
              &lt;input type="checkbox" name="checkboxsupply" id="5" value="(1 Quanity) Pack of pencil cap erasers"&gt;
              &lt;label for="5"&gt;(1 Quanity) Pack of pencil cap erasers&lt;/label&gt;
          &lt;/fieldset&gt;
          &lt;fieldset data-role="controlgroup" id="hoursName"&gt;
              &lt;legend&gt;&lt;strong&gt;Third Grade Supply List:&lt;/strong&gt;&lt;/legend&gt;
              &lt;input type="checkbox" name="checkboxsupply" id="1" value="(48 Quanity) #2 6-sided pencils (sharpened preferred)" &gt;
              &lt;label for="1"&gt;(48 Quanity) #2 6-sided pencils (sharpened preferred)&lt;/label&gt;
              &lt;input type="checkbox" name="checkboxsupply" id="2" value="(2 Quanity) Red pencils"&gt;
              &lt;label for="2"&gt;(2 Quanity) Red Pencils&lt;/label&gt;
              &lt;input type="checkbox" name="checkboxsupply" id="3" value="(1 Quanity) Pack of pink erasers"&gt;
              &lt;label for="3"&gt;(1 Quanity) Pack of pink erasers&lt;/label&gt;
              &lt;input type="checkbox" name="checkboxsupply" id="4" value="(1 Quanity) Box of Kleenex (tissue)"&gt;
              &lt;label for="4"&gt;(1 Quanity) Box of Kleenex (tissue)&lt;/label&gt;
              &lt;input type="checkbox" name="checkboxsupply" id="5" value="(1 Quanity) Pack of pencil cap erasers"&gt;
              &lt;label for="5"&gt;(1 Quanity) Pack of pencil cap erasers&lt;/label&gt;
          &lt;/fieldset&gt;
          &lt;fieldset data-role="controlgroup" id="hoursName"&gt;
              &lt;legend&gt;&lt;strong&gt;Forth Grade Supply List:&lt;/strong&gt;&lt;/legend&gt;
              &lt;input type="checkbox" name="checkboxsupply" id="1" value="(48 Quanity) #2 6-sided pencils (sharpened preferred)" &gt;
              &lt;label for="1"&gt;(48 Quanity) #2 6-sided pencils (sharpened preferred)&lt;/label&gt;
              &lt;input type="checkbox" name="checkboxsupply" id="2" value="(2 Quanity) Red pencils"&gt;
              &lt;label for="2"&gt;(2 Quanity) Red Pencils&lt;/label&gt;
              &lt;input type="checkbox" name="checkboxsupply" id="3" value="(1 Quanity) Pack of pink erasers"&gt;
              &lt;label for="3"&gt;(1 Quanity) Pack of pink erasers&lt;/label&gt;
              &lt;input type="checkbox" name="checkboxsupply" id="4" value="(1 Quanity) Box of Kleenex (tissue)"&gt;
              &lt;label for="4"&gt;(1 Quanity) Box of Kleenex (tissue)&lt;/label&gt;
              &lt;input type="checkbox" name="checkboxsupply" id="5" value="(1 Quanity) Pack of pencil cap erasers"&gt;
              &lt;label for="5"&gt;(1 Quanity) Pack of pencil cap erasers&lt;/label&gt;
          &lt;/fieldset&gt;
          &lt;fieldset data-role="controlgroup" id="hoursName"&gt;
              &lt;legend&gt;&lt;strong&gt;Fifth Grade Supply List:&lt;/strong&gt;&lt;/legend&gt;
              &lt;input type="checkbox" name="checkboxsupply" id="1" value="(48 Quanity) #2 6-sided pencils (sharpened preferred)" &gt;
              &lt;label for="1"&gt;(48 Quanity) #2 6-sided pencils (sharpened preferred)&lt;/label&gt;
              &lt;input type="checkbox" name="checkboxsupply" id="2" value="(2 Quanity) Red pencils"&gt;
              &lt;label for="2"&gt;(2 Quanity) Red Pencils&lt;/label&gt;
              &lt;input type="checkbox" name="checkboxsupply" id="3" value="(1 Quanity) Pack of pink erasers"&gt;
              &lt;label for="3"&gt;(1 Quanity) Pack of pink erasers&lt;/label&gt;
              &lt;input type="checkbox" name="checkboxsupply" id="4" value="(1 Quanity) Box of Kleenex (tissue)"&gt;
              &lt;label for="4"&gt;(1 Quanity) Box of Kleenex (tissue)&lt;/label&gt;
              &lt;input type="checkbox" name="checkboxsupply" id="5" value="(1 Quanity) Pack of pencil cap erasers"&gt;
              &lt;label for="5"&gt;(1 Quanity) Pack of pencil cap erasers&lt;/label&gt;
          &lt;/fieldset&gt;
          &lt;fieldset data-role="controlgroup" id="hoursName"&gt;
              &lt;legend&gt;&lt;strong&gt;Sixth Grade Supply List:&lt;/strong&gt;&lt;/legend&gt;
              &lt;input type="checkbox" name="checkboxsupply" id="1" value="(48 Quanity) #2 6-sided pencils (sharpened preferred)" &gt;
              &lt;label for="1"&gt;(48 Quanity) #2 6-sided pencils (sharpened preferred)&lt;/label&gt;
              &lt;input type="checkbox" name="checkboxsupply" id="2" value="(2 Quanity) Red pencils"&gt;
              &lt;label for="2"&gt;(2 Quanity) Red Pencils&lt;/label&gt;
              &lt;input type="checkbox" name="checkboxsupply" id="3" value="(1 Quanity) Pack of pink erasers"&gt;
              &lt;label for="3"&gt;(1 Quanity) Pack of pink erasers&lt;/label&gt;
              &lt;input type="checkbox" name="checkboxsupply" id="4" value="(1 Quanity) Box of Kleenex (tissue)"&gt;
              &lt;label for="4"&gt;(1 Quanity) Box of Kleenex (tissue)&lt;/label&gt;
              &lt;input type="checkbox" name="checkboxsupply" id="5" value="(1 Quanity) Pack of pencil cap erasers"&gt;
              &lt;label for="5"&gt;(1 Quanity) Pack of pencil cap erasers&lt;/label&gt;
          &lt;/fieldset&gt;
      &lt;/form&gt;
      &lt;button class="ui-btn ui-corner-all Create"&gt;Create List&lt;/button&gt;
  
  
  &lt;/article&gt;&lt;!--content--&gt;
  &lt;/section&gt;
  </code></pre>
  
  <p>Here is the javascript that I have</p>
  
  <pre><code>&lt;div data-role="page" id="nameList"&gt;&lt;/div&gt;
  &lt;script id="jsbin-javascript"&gt;
  $(".Create").on("click", function() {
      var selectedValues = "";
      $checkedCheckboxes = $("input:checkbox[name=checkboxsupply]:checked");
      $checkedCheckboxes.each(function () {
          $('#nameList').append('&lt;li&gt;' + $(this).val() + '&lt;/li&gt;');
      });
      window.location = "#nameList";
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>Any suggestions would be great, I have tried using jquery as a way to count up the quantity but had no luck.</p>
  
  <p>Thanks again.</p>