title: How to pass the loop values into string separated by comma in javascript
body: <p>In the below code I am fetching the values which will select in "Right Side Box" (i.e one, two,three). </p>
  
  <pre><code>___________      __________
  
      four   |    |
  
             |&gt;   |one
  
      five   |&lt;   |two
  
             | &gt;&gt; |three
  
             |&lt;&lt;  |
                  __________
  </code></pre>
  
  <p>Code is:</p>
  
  <pre><code>function Selected()
  {
  
      var menu = document.getElementById('selectedServersID').length;
      alert(menu);
      for (var i=0; i&lt;menu; i++)
      {
  
          var selectedcol = document.getElementById('selectedServersID')[i].value;
          //var selectedcol = document.getElementById('selectedServersID')[i].innerHTML;
          alert(selectedcol);
  
      }
  
  }
  </code></pre>
  
  <p>The above code fetches all the values present in the rightside box. Now,I need to get all the values from the "For loop" and need to add to the string separated by Comma. out side the for loop how to create the string and store all the values separated by comma? plz help.</p>