[WooCommerce] Using a select field for quantity

wordpress
phpscripts
javascript

#1

I have been using the standard text input field for quantity, but i’d like to use a select dropdown instead, to display it on cart page. How do i make it ajax, so it will update both total and etc. each time i choose a new quantity? I have this code so far, snippet found on the internet.

/* Change Product Quantity Input to Dropdown */
function woocommerce_quantity_input() {
 global $product;

 $defaults = array(
  'input_name' => 'quantity',
  'input_value' => '1',
  'max_value'  => apply_filters( 'woocommerce_quantity_input_max', '', $product ),
  'min_value'  => apply_filters( 'woocommerce_quantity_input_min', '', $product ),
  'step'   => apply_filters( 'woocommerce_quantity_input_step', '1', $product ),
  'style'   => apply_filters( 'woocommerce_quantity_style', 'float:left; margin-right:10px;', $product )
 );

 if (!empty($defaults['min_value']))
  $min = $defaults['min_value'];
  else $min = 1;

 if (!empty($defaults['max_value']))
  $max = $defaults['max_value'];
  else $max = 20;

 if (!empty($defaults['step']))
  $step = $defaults['step'];
  else $step = 1;

 $options = '';
 for($count = $min;$count <= $max;$count = $count+$step){
  $options .= '<option value="' . $count . '">' . $count . '</option>';
 }

 echo '<div class="quantity_select" style="' . $defaults['style'] . '"><select name="' . esc_attr( $defaults['input_name'] ) . '" title="' . _x( 'Qty', 'Product quantity input tooltip', 'woocommerce' ) . '" class="qty">' . $options . '</select></div>';
}

This isn’t ajax, and therefor doesnt work at all on cart page (it does display a select dropdown). Thanks.