title: How do I append multiple variables to a url using javascript?
body: <p>I am having trouble appending multiple variables to the end of a url using javascript.  The user provides input on the page using a select menu and textarea.  Using just the textarea works, but I’m not able to include the select menu. </p>
  
  <pre><code>&lt;?php
  $price = $_GET['price'];
  $title = $_GET['title'];
  $retailer = $_GET['retailer'];
  $img = $_GET['img'];
  $link = $_GET['link'];
  $desc = $_GET['desc'];    
  ?&gt;
  
  &lt;textarea rows="3" id="textarea" class="input-xlarge" placeholder="Size, color, style, etc" name ="options"&gt;&lt;/textarea&gt;
  
  &lt;select style="width: 130px;" id="quantity" class="span2"&gt;
          &lt;option value="1"&gt;1&lt;/option&gt;
          &lt;option value="2"&gt;2&lt;/option&gt;
          &lt;option value="3"&gt;3&lt;/option&gt;
          &lt;/select&gt;
  
  &lt;script language="javascript"&gt;
      function test()
  {
      var val=document.getElementById("textarea").value;  
      var val=document.getElementById("quantity").value; 
      var hrf="viewcart.php?retailer=&lt;?php echo $retailer?&gt;&amp;link=&lt;?php echo $link; ?&gt;&amp;price=&lt;?php echo $price; ?&gt;&amp;title=&lt;?php echo $title; ?&gt;&amp;options="+val;
      document.getElementById("a_link").href=hrf;
  }
  &lt;/script&gt;
  
  &lt;a href ="#" id="a_link" onclick="test();" class="btn btn-success" type="submit"&gt;
      &lt;i class="icon-shopping-cart icon-white"&gt;&lt;/i&gt;  Add to Cart
  &lt;/a&gt;
  </code></pre>
  
  <p>The line I am trying to alter is: </p>
  
  <pre><code>    var hrf="viewcart.php?retailer=&lt;?php echo $retailer?&gt;&amp;link=&lt;?php echo $link; ?&gt;&amp;price=&lt;?php echo $price; ?&gt;&amp;title=&lt;?php echo $title; ?&gt;&amp;options="+val;
  </code></pre>
  
  <p>I tried to have the below but it didn’t work:</p>
  
  <pre><code>    var hrf="viewcart.php?retailer=&lt;?php echo $retailer?&gt;&amp;link=&lt;?php echo $link; ?&gt;&amp;price=&lt;?php echo $price; ?&gt;&amp;title=&lt;?php echo $title; ?&gt;&amp;options="+val + “&amp;quantity=” + quantity;
  </code></pre>
  
  <p>Any ideas on how to get this to work?</p>