title: How can I add multiple values to an input box with comma separated using jQuery
body: <p>Here's my code:</p>
  
  <pre><code>$("#fillMemberTable").click(function(e) {
      var tableBody = new Array();
  
      // add object
      tableBody = "&lt;tr id='tr" + result.id + "'&gt;"
              + "&lt;td&gt;" + result.code + "&lt;/td&gt; "
              + "&lt;td&gt;" + result.name + " &lt;/td&gt;"
              + "&lt;td&gt;" + result.family + " &lt;/td&gt;"
              + "&lt;td&gt;" + result.fatherName + "&lt;/td&gt;"
              + "&lt;td&gt;" + result.nationalCode + "&lt;/td&gt;"
              + "&lt;td&gt;" + result.defaultUserContact_mobileNo + "&lt;/td&gt;"
              + "&lt;td&gt;" + result.valid + "&lt;/td&gt;"
              + "&lt;td&gt;&lt;input type='button'  id='" + result.id + "' value='&lt;spring:message code="form.btnDelete"/&gt;'&gt;&lt;/td&gt;&lt;/tr&gt;";
  
      //add to the table
      $("#membersTable").append(tableBody);
      //$("#members").val(result.id);
  
      e.preventDefault();
  
      var elem = $(this).parent().find('input[name=members\\[\\]]');
      elem.val(elem.val() + ',');
      //            $("#members").val(elem);
  
      $("#members").val(elem.toString());
      // The remove button click
      $("#" + result.id).click(function() {
          var buttonId = $(this).attr("id");
          //write the logic for removing from the array
          $("#tr" + buttonId).remove();
          $("#members").val('');
      });
  });
  </code></pre>
  
  <p>And HTML code : </p>
  
  <pre><code>&lt;div class="form-group"&gt;
      &lt;label class="col-sm-3 control-label"&gt;&lt;spring:message code="core.Specifications" /&gt;: &lt;/label&gt;
      &lt;div class="col-sm-8"&gt;
          &lt;label  id="lblMemberSpecifications"&gt;&lt;/label&gt;
      &lt;/div&gt;
      &lt;div&gt;
          &lt;input type="button" id="fillMemberTable"  class="btn btn-default" value="&lt;spring:message code="core.Submit" /&gt;" /&gt;
      &lt;/div&gt;
  &lt;/div&gt;   
  &lt;div class="form-group"&gt;               
      &lt;input type="text" id="members" name="core[members]" /&gt;
  &lt;/div&gt; 
  
  &lt;div class="form-group"&gt;
      &lt;div &gt;
          &lt;table id="membersTable" class="table table-bordered" style=" width: auto;  margin-left: auto; margin-right: auto;"&gt;
              &lt;thead&gt;
                  &lt;tr&gt;
                      &lt;th style="width: 100px; text-align: center"&gt;&lt;spring:message code="core.MemberCode" /&gt;&lt;/th&gt;
                      &lt;th style="width: 100px; text-align: center"&gt;&lt;spring:message code="core.MemberFname" /&gt;&lt;/th&gt;
                      &lt;th style="width: 100px; text-align: center"&gt;&lt;spring:message code="core.MemberLname" /&gt;&lt;/th&gt;
                      &lt;th style="width: 100px; text-align: center"&gt;&lt;spring:message code="core.memberFatherName" /&gt;&lt;/th&gt;
                      &lt;th style="width: 100px; text-align: center"&gt;&lt;spring:message code="core.MemberNationalcode" /&gt;&lt;/th&gt;
                      &lt;th style="width: 100px; text-align: center"&gt;&lt;spring:message code="core.cellPhone" /&gt;&lt;/th&gt;
                      &lt;th style="width: 100px; text-align: center"&gt;&lt;spring:message code="core.userStatus" /&gt;&lt;/th&gt;
                      &lt;th style="width: 100px;" &gt;&lt;/th&gt;
                  &lt;/tr&gt;
              &lt;/thead&gt;
          &lt;/table&gt;
      &lt;/div&gt;  
  &lt;/div&gt;
  </code></pre>
  
  <p>I want get result values and set this values in a input box va separated with comma , but code doesn't work.</p>
  
  <p>Thank you.</p>