Note that there are some explanatory texts on larger screens.

plurals
  1. POpass multiple textbox box values to controller in CodeIgniter
    primarykey
    data
    text
    <p>I want to send multiple textbox values to CodeIgniter .. I dont know why this code is not working .. </p> <p>here is my view </p> <pre><code> &lt;th&gt;Items:&lt;/th&gt; &lt;th&gt;Price:&lt;/th&gt; &lt;th&gt;quantity:&lt;/th&gt; &lt;th&gt;total:&lt;/th&gt; &lt;/tr&gt; &lt;?php for ($i = 0; $i &lt; 5; $i++) {?&gt; &lt;tr&gt; &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; &lt;?php echo form_dropdown('item_id[]', $records3, '#', "id='items_".$i."'"); ?&gt; &lt;/td&gt; </code></pre> <p>the items dropdown options are coming against the category .. means if i select some thing from category then items will display against to that category</p> <pre><code> &lt;td&gt;&lt;input type="text" name =&lt;?php echo $price;?&gt; id = "price_"&lt;?php echo $i ?&gt;&gt; &lt;/td&gt; &lt;td&gt;&lt;input type="text" name =&lt;?php echo quantity;?&gt; id = "price_"&lt;?php echo $i ?&gt; </code></pre> <p>i have set the field name of price and quantity to 'price' and 'quantity'</p> <p>here is my controller..</p> <pre><code>$data3 = array( 'item_id' =&gt; $this-&gt;input-&gt;post('item_id'), 'price' =&gt; $this-&gt;input-&gt;post('price'), 'quantity' =&gt; $this-&gt;input-&gt;post('quantity'), ); $data4 = array(); for($i = 0; $i &lt; 5; $i++) { $data4 = array ( 'item_id' =&gt; $data3['item_id'][$i], 'price' =&gt; $data3['price'][$i], 'quantity' =&gt; $data3['quantity'][$i], ); } $this-&gt;load-&gt;model('salesModel'); $this-&gt;salesModel-&gt;addSoldItemtoDB($data4); </code></pre> <p>the problem is price value "null " is going into the database and same for the quantity and as far as item_id concern whatever i select in item it is saving id '1' in database..</p> <p>my java-script for functionality of two drop down boxes above . categories and items</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>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload