title: Get input before submitting to insert into action url
body: <p>Im trying to get a value of an input into my buttons action url before the button is pushed.</p>
  
  <p>I need to get the value of:  </p>
  
  <pre><code>id="qty&lt;?php echo $i;?&gt;"
  </code></pre>
  
  <p>Into where it says: </p>
  
  <pre><code>&lt;?php echo VALUE OF $qtyforaction; ?&gt;
  </code></pre>
  
  <p>My Code is:</p>
  
  <pre><code>       &lt;?php $i = $_product-&gt;getId();?&gt;
  
              &lt;form action="&lt;?php echo $this-&gt;helper('checkout/cart')-&gt;getAddUrl($_product); ?&gt;" method="post" id="product_addtocart_form_&lt;?php echo $_product-&gt;getId()?&gt;"&lt;?php if($_product-&gt;getOptions()): ?&gt; enctype="multipart/form-data"&lt;?php endif; ?&gt;&gt;
  
                  &lt;input type="text" name="qty" id="qty&lt;?php echo $i;?&gt;" maxlength="12" value="1" title="Qty" class="cartnum" /&gt;
  
                  &lt;?php $qtyforaction = 'qty'.$i; ?&gt;
                  &lt;?php echo $qtyforaction; ?&gt;
  
  
                  &lt;button type="button" class="addtocartbutton button btn-cart" onclick="setLocation('&lt;?php echo $this-&gt;helper('checkout/cart')-&gt;getAddUrl($_product); ?&gt;qty/&lt;?php echo VALUE OF $qtyforaction; ?&gt;')" &gt;&lt;span&gt;&lt;span&gt;Order Again&lt;/span&gt;&lt;/span&gt;&lt;/button&gt;
  
            &lt;/form&gt;
  </code></pre>
  
  <p>Would I have to use javascript to get it into the url string? My javascript is a bit ropey, would something like this work?</p>
  
  <pre><code>     &lt;script type="text/javascript"&gt;
          var something= document.getElementById('&lt;?php echo $qtyforaction;?&gt;');
       &lt;/script&gt;
  </code></pre>
  
  <p>UPDATE WITH FULL CODE:</p>
  
  <pre><code>&lt;?php
  if (Mage::getSingleton('customer/session')-&gt;isLoggedIn()) {
  
  /* Get the customer data */
  $customer       = Mage::getSingleton('customer/session')-&gt;getCustomer();
  /* Get the customer's email address */
  $customer_email = $customer-&gt;getEmail();
  
  }
  
  $collection = Mage::getModel('sales/order')-&gt;getCollection()-&gt;addAttributeToFilter('customer_email', array(
  'like' =&gt; $customer_email
  ));
  
  
  
  $uniuqProductSkus = array();
  
  foreach ($collection as $order) { 
  
      $order_id = $order-&gt;getId(); 
      $order = Mage::getModel("sales/order")-&gt;load($order_id); 
      $ordered_items = $order-&gt;getAllItems(); 
          foreach ($ordered_items as $item) 
          { 
          if (in_array($item-&gt;getProduct()-&gt;getSku(), $uniuqProductSkus)) { 
          continue; 
          } else { 
              array_push($uniuqProductSkus, $item-&gt;getProduct()-&gt;getSku()); 
  
              $_product                 = Mage::getModel('catalog/product')-&gt;load($item-&gt;getProductId());
              $product_small_image_path = Mage::helper('catalog/image')-&gt;init($_product, 'small_image')-&gt;resize(200);
              $product_thumbnail_path   = Mage::helper('catalog/image')-&gt;init($_product, 'small_image')-&gt;resize(150);
              $summaryData              = Mage::getModel('review/review_summary')-&gt;load($item-&gt;getProductId());
  
              echo "&lt;li&gt;";
  
              echo "&lt;div class='previous-name'&gt;&lt;p&gt;&lt;a  style='color:black; font-weight:bold; font-size:14px;' href='" . $_product-&gt;getProductUrl() . "'&gt;";
              echo $item-&gt;getName() . "&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;";
  
              echo "&lt;div class='previous-image'&gt;&lt;a href='" . $_product-&gt;getProductUrl() . "'&gt;";
              echo "&lt;img src='" . $product_small_image_path . "' /&gt;";
              echo "&lt;/a&gt;&lt;/div&gt;";
  
              echo "&lt;div class='previous-rating'&gt;";
              echo "&lt;p&gt;&lt;a  style='color:black; font-weight:bold; font-size:14px;' href='" . $_product-&gt;getProductUrl() . "#product_tabs_review_tabbed'&gt;Review this beer now&lt;/a&gt;&lt;/p&gt;";
  
              echo $summaryData-&gt;getRatingSummary() . '% Would buy again &lt;br/&gt;';
  
              echo "&lt;div class='rating-box' style='float:left;'&gt;";
              echo "&lt;div class='rating' style='width:" . $summaryData-&gt;getRatingSummary() . "%'&gt;&lt;/div&gt;&lt;/div&gt;";
              echo "&lt;/div&gt;";
  
  
              /**echo "&lt;div class='previous-button'&gt;";
              echo '&lt;button type="button" title="Add to Cart" class="button btn-cart" onclick="setLocation(\'';
              echo $this-&gt;helper('checkout/cart')-&gt;getAddUrl($_product);
              echo '\')"&gt;&lt;span&gt;&lt;span&gt;Order Again&lt;/span&gt;&lt;/span&gt;&lt;/button&gt;';
              echo "&lt;/div&gt;";**/
  
              ?&gt;
  
              &lt;?php $i = $_product-&gt;getId();?&gt;
              &lt;div class='previous-button'&gt;
              &lt;form action="&lt;?php echo $this-&gt;helper('checkout/cart')-&gt;getAddUrl($_product); ?&gt;" method="post" id="product_addtocart_form_&lt;?php echo $_product-&gt;getId()?&gt;"&lt;?php if($_product-&gt;getOptions()): ?&gt; enctype="multipart/form-data"&lt;?php endif; ?&gt;&gt;
  
                  &lt;input type="text" name="qty" id="qty&lt;?php echo $i;?&gt;" maxlength="12" value="1" title="Qty" class="cartnum" /&gt;
  
                  &lt;?php $qtyforaction = 'qty'.$i; ?&gt;
  
                  &lt;script type="text/javascript"&gt;
                      var xy = document.getElementsByTagName("input")[0].getAttribute("qty");
                      var x = "&lt;button type='button' class='addtocartbutton  button btn-cart' onclick='setLocation()'&gt;&lt;span&gt;&lt;span&gt;Order Again&lt;/span&gt;&lt;/span&gt;&lt;/button&gt;";
                       document.getElementById("buttonaddcart").innerHTML = x;
                   &lt;/script&gt;
                   &lt;div id="buttonaddcart"&gt;
                  &lt;button type="button" class="addtocartbutton button btn-cart" onclick="setLocation('&lt;?php echo $this-&gt;helper('checkout/cart')-&gt;getAddUrl($_product); ?&gt;qty/')" &gt;&lt;span&gt;&lt;span&gt;Order Again&lt;/span&gt;&lt;/span&gt;&lt;/button&gt;
                   &lt;/div&gt;
  
              &lt;/form&gt;
              &lt;/div&gt;
  
  
              &lt;?php
              echo "&lt;div class='previous-clear'&gt;&lt;/div&gt;";
  
              echo "&lt;/li&gt;";
  
      }
   }
  }
  ?&gt; 
  </code></pre>