title: pass multiple textbox values to controller Code igniter
body: <p>I am newbie in <a href="http://ellislab.com/codeigniter" rel="nofollow">Codeigniter</a> so I don't know how to do this.<br>
  Actually my view page has five rows which I generated through for loop in which each row contain two select boxes and two input boxes. I don't know how to get these values first in <strong>jQuery</strong> and then pass into controller. Actually I know how to grab values from a simple textboxes but because I generate them in a loop and give them a separate id, so I don't know how to get the values in jQuery and then pass to the controller.  </p>
  
  <p>This is my view</p>
  
  <pre><code>       &lt;tr&gt;
          &lt;th&gt;Category:&lt;/th&gt;
      &lt;th&gt;Items:&lt;/th&gt;
         &lt;th&gt;Selling Price:&lt;/th&gt;
          &lt;th&gt;quantity:&lt;/th&gt;
  
  &lt;/tr&gt;
  
      &lt;?php for ($i = 0; $i &lt; 5; $i++) {
  
      ?&gt;
      &lt;tr&gt; //Categories
  &lt;td&gt;&lt;?php echo form_dropdown('cat_id', $records2, '#', 
          "id='category_".$i."'  onchange='getItems(this.value,".$i.")' ");?&gt;
                          &lt;/td&gt;
            &lt;!-- Items --&gt;
  
    &lt;td&gt;form_dropdown('item_id', $records3, '#', "id='items_".$i."'"); ?&gt; &lt;/td&gt;
      &lt;!-- end of Items --&gt;
  
  
  
      &lt;td&gt; &lt;?php echo form_input($price); ?&gt;&lt;/td&gt;
  
  &lt;td&gt;&lt;?php echo form_input($quantity); }?&gt;&lt;/td&gt;
  </code></pre>
  
  <p>The item options is based on the categories selection, means if I select some option from categories, then the items against categories show in a second select box.</p>
  
  <p>Here is my Javascript for functionality of top  two select boxes</p>
  
  <pre><code>    &lt;script type="text/javascript"&gt;
  
  function getItems(category_id,index) {
  
         $("#items_" + index + " &gt; option").remove(); 
  
      $.ajax({
          type: "POST",
          url: "stockInController/get_Items/"+category_id, 
          success: function(items) 
          {
              $.each(items,function(item_id,item_name) 
              {
                  var opt = $('&lt;option /&gt;'); 
                  opt.val(item_id);
                  opt.text(item_name);
                  $('#items_'+ index).append(opt); 
              });
          }
  
      });
  }
   &lt;/script&gt; 
  </code></pre>
  
  <p>Now the problem is here; I want to get the values from all the rows and then pass into controller.<br>
  This is the javascript for catching and then sending values to controller</p>
  
  <pre><code>  &lt;script type="text/javascript"&gt;
   $('#btns').click(function() { //  $("#form").serialize()
  </code></pre>
  
  <p>Here, I am not doing right, first I don't know how to get values of item and categories here and then the other thing is how to be able to get multiple textbox values because there are five rows, and the textvalues in which values are filled are to be sent    </p>
  
  <pre><code>var item_id = $('#items').val();   
  var item_id = $('#items').val();
  
  
  var price = $('#price').val();
  var quantity = $('#quantity').val();
  
  
  
  
  var form_data = {
          cat_id: $('#cat_id').val(),
  
          quantity: $('#quantity').val(),
          item_id: $('#items').val(),
  
  
  
  
  };
  
  
  $.ajax({
      url: "&lt;?php echo site_url('salesController/addSales'); ?&gt;",
      type: 'POST',
      data: form_data,
      dataType: 'json',
      success: function(msg) {
          if(msg.res == 1)
          {
  
              alert("true");
          }
          else{
              alert("false");          
            }
  
  
      }
  });
  
  return false;
      });
  
  
  &lt;/script&gt;
  </code></pre>
  
  <p>Here is my controller and I don't know to get multiple values here also.<br>
  Here is the code of what I am doing, I know I am wrong, but I don't know how to make it right </p>
  
  <pre><code>       $data = array(
              'cat_id' =&gt; $this-&gt;input-&gt;post('cat_id'),
  
              'item_id' =&gt; $this-&gt;input-&gt;post('item_id'),
              'price' =&gt; $this-&gt;input-&gt;post('sales_date'),
              'quantity' =&gt; $this-&gt;input-&gt;post('sales_bill_no'),
  
              );
  </code></pre>