title: How to get values from two textboxes and display on third on button click using Javascript?
body: <p>I two groups and every group have two textboxes. Now I want get values of all text boxes and display in third in this format:
  2 apple, 3 watermelon</p>
  
  <p>I will explain better with example:</p>
  
  <pre><code>I want this:
  
  Group 1
  Textbox1 = 2
  Textbox2 = apple
  
  Group 2
  Textbox1 = 3
  Textbox2 = watermelon
  
  and third should looks like this:
  Textbox3 = 2 apple, 3 watermelon
  </code></pre>
  
  <p>This is simple html code:</p>
  
  <pre><code>&lt;input type="text" name="text1"&gt;&lt;br /&gt;
  &lt;input type="text" name="text2"&gt;&lt;br /&gt;
  
  &lt;br/&gt;&lt;br/&gt;
  
  &lt;input type="text" name="text1"&gt;&lt;br /&gt;
  &lt;input type="text" name="text2"&gt;&lt;br /&gt;
  
  &lt;input type="submit" value="Add" id="getValue"&gt;
  
  &lt;br /&gt;&lt;br /&gt;
  &lt;input type="text" id="text3" /&gt;
  </code></pre>
  
  <p>I have tried to do like this, and works only with textbox 1, I don't know how to add second textbox in javascript.</p>
  
  <pre><code>$(function () {
  
              $('#getValue').click(function() {
                  $('#text3').val('');
                  var values = [];
  
                  $('input[name="text1"]').each(function(i, elem) {
                      $("#text3").val(($("#text3").val() + ', ' + $(elem).val()).replace(/^, /, ''));
                  });
  
  
              });
          });
  </code></pre>