title: How to correctly replace input field for quantity by select option quantity field?
body: <p>I have an addtocart button with a quantity input field that is properly functioning in my website (see image below):</p>
  
  <p><a href="https://i.stack.imgur.com/yJRxJ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yJRxJ.jpg" alt="Working add to cart"></a></p>
  
  <p>When I introduce for example 2 in the input field and push the addtocart button, my cart gets updated with 2 items.</p>
  
  <p>But I want to change the quantity input field by a dropdown field so the visitor can only select one of the allowed quantities in the dropdown list. I can get dropdown field properly configured, but when I click on the addtocart button (see image below), nothing happens.</p>
  
  <p><a href="https://i.stack.imgur.com/1ty08.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1ty08.jpg" alt="Not working select field"></a></p>
  
  <p>I suppose I need to change "input" by "select" somewhere in the javascript. Or maybe the quantity or button in the javascript is not correctly transmitted? </p>
  
  <p>I can't get it working after some trials. </p>
  
  <p>Can anybody help me with this? I would be very pleased (always struggling with javascript)</p>
  
  <p>Thanks.</p>
  
  <p>The html code for the input field (working) is:</p>
  
  <pre><code>&lt;input type="hidden" value="&lt;?=$product['product_id']?&gt;" size="2" name="product_id" /&gt;
          &lt;input type="hidden" value="&lt;?=$product['gift_products_id']?&gt;" size="2" name="gift_products_id" /&gt;
          &lt;? if($product['quantity']!==$product['total']){  ?&gt;
          &lt;input type="text" value="1" size="2" name="quantity" /&gt;
          &lt;a class="btn btn-primary addtocart" lang="&lt;?=$product['product_id']?&gt;" href="javascript:void(0)" &gt;&lt;span&gt;&lt;?=$_['gr_m_add_to_cart']?&gt;&lt;/span&gt;&lt;/a&gt;
          &lt;? } ?&gt;
  </code></pre>
  
  <p>The html code for the "select option" field, properly configured but not working is:</p>
  
  <pre><code>&lt;input type="hidden" value="&lt;?=$product['product_id']?&gt;" size="2" name="product_id" /&gt;
  &lt;input type="hidden" value="&lt;?=$product['gift_products_id']?&gt;" size="2" name="gift_products_id" /&gt;
  &lt;? if($product['quantity']!==$product['total']){  ?&gt;
  &lt;select name="quantity" class="form-control_cart" id="input-quantity" value="1" &gt;
       &lt;?php foreach (range(1, $product['quantity'], 1) as $stap) {
            if ($stap == 1) {
                  echo "&lt;option value='$stap' selected&gt;$stap&lt;/option&gt;";
            } else {
                  echo "&lt;option value='$stap'&gt;$stap&lt;/option&gt;";
            }
          }  ?&gt;
  &lt;/select&gt;
  &lt;a class="btn btn-default addtocart" style="margin-top:-4px" lang="&lt;?=$product['product_id']?&gt;" href="javascript:void(0)"  data-toggle="tooltip" title="&lt;?=$_['gr_m_add_to_cart']?&gt;"&gt;&lt;i class="fa fa-shopping-cart"&gt;&lt;/i&gt;&lt;/a&gt;                       
  &lt;? } ?&gt;
  </code></pre>
  
  <p>The javascript code that is used for the addtocart button:</p>
  
  <pre><code>$('.addtocart').click(function() {
  id = $(this).attr('lang');
  $.ajax({
      url: 'index.php?route=checkout/cart/add',
      type: 'post',
      data: $('#row_'+id+' input[type=\'text\'], #row_'+id+' input[type=\'hidden\']'),
      dataType: 'json',
      beforeSend: function() {
          //$('#button-cart').button('loading');
          $('.addtocart').button('loading');
      },
      complete: function() {
          //$('#button-cart').button('reset');
          $('.addtocart').button('reset');
      },
      success: function(json) {
          $('.alert, .text-danger').remove();
          $('.form-group').removeClass('has-error');
  
          if (json['error']) {
              if (json['error']['option']) {
                  for (i in json['error']['option']) {
                      var element = $('#input-option' + i.replace('_', '-'));
  
                      if (element.parent().hasClass('input-group')) {
                          element.parent().after('&lt;div class="text-danger"&gt;' + json['error']['option'][i] + '&lt;/div&gt;');
                      } else {
                          element.after('&lt;div class="text-danger"&gt;' + json['error']['option'][i] + '&lt;/div&gt;');
                      }
                  }
              }
  
              if (json['error']['recurring']) {
                  $('select[name=\'recurring_id\']').after('&lt;div class="text-danger"&gt;' + json['error']['recurring'] + '&lt;/div&gt;');
              }
  
              // Highlight any found errors
              $('.text-danger').parent().addClass('has-error');
          }
  
          if (json['success']) {
              if (!Journal.showNotification(json['success'], json['image'])) {
                  $('.breadcrumb').after('&lt;div class="alert alert-success success"&gt;' + json['success'] + '&lt;button type="button" class="close" data-dismiss="alert"&gt;&amp;times;&lt;/button&gt;&lt;/div&gt;');
              }
  
              $('#cart-total').html(json['total']);
  
              $('html, body').animate({ scrollTop: 0 }, 'slow');
  
              $('#cart ul').load('index.php?route=common/cart/info ul li');
          }
      }
  });
  });
  </code></pre>
  
  <p></p>