CodeIgniter Forums

Full Version: Values from textbox array not updating
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi guys, Im new in this forum and i'm having a hard time updating selected value from checkbox coming from the textbox value. 


I want to update selected items, For example I want to update Item-2 and the textbox from item recieve will be enable, I will enter a number for example 1 and the textbox from total receive will automatically sum using ajax.

The problem is after submiting the value from total recieve the records that was updating is blank, but when I try to check and print_r the value is there.

And one more thing if all checkbox are all checked and enter a number for each item recieve, the value that it only get is the last value and will be updated will all selected checkbox.

Checkbox is an array
Textbox from total recieve is an array

Can you guys please help me?

Here's my UI:

[Image: w5jkp.jpg]

Here's my code.

public function recitem_insert(){


$check = $this->input->post('check');    
$total_rec = $_POST['total_rec'];

if(isset($check)){ //Check if check is checked    

    $updateData = array('rec_qty' => $total_rec[$j] );                                                        
    $this->dbquery->modUpdatedynamicval('tblstock', 'id', $updateData, $check[$i]);

   }//end for loop    

    echo "<script type='text/javascript'>
        alert('Successfully Added!');
}else{ //End If
      echo 'Please select a checkbox';



<form method="post" action="<?php echo base_url() ?>user/recitem_insert">

<div class="box">
<div class="box-header">
<h3 class="box-title">System ID: <b><?php echo $process_id; ?></b></h3>
<!-- /.box-header -->
<div class="box-body">
<table id="example1" class="table table-bordered table-striped">
<th>Item Code</th>
<th>Item Description</th>
<th>Required QTY Order</th>
<th>Last QTY Recieve</th>
<th>Item Recieve</th>
<th>Total Recieve</th>



$query = $this->db->query("SELECT * FROM tblstock where process_id = '$process_id'");
foreach ($query->result() as $row){                                      

<td><input type="checkbox" name="check[]" id="opt" value="<?php echo $row->id; ?>" onclick="valueChanged()"> </td>
<td><?php echo $row->item_code; ?></td>
<td><?php echo $row->description; ?></td>
<td><?php echo $row->qty_order; ?></td>
<td><?php echo $row->rec_qty; ?></td>

<input type="hidden" name="last_item_rec[]"  value="<?php echo $row->rec_qty;  ?>">

<td><input type="text" name="item_rec[]"  id="txt" disabled=""></td>  
<td><input type="text" name="total_rec[]"></td>  





<!-- /.box-body -->

<div class="box-footer">
<button type="submit" class="btn bg-olive btn-flat margin">Submit</button>



public function modUpdatedynamicval($table, $column, $data, $equal_to){
$this->db->where($column, $equal_to);
$this->db->update($table, $data);         

Any help will be gladly appreciate.

Thank you..


Lets assume, I've input 1 in item_receive textbox one and the total recieve will be 10, 2 in item_receive textbox two and the total recieve will be 11, 3 in item_receive textbox three and the total recieve will be 12,

[Image: yngJo.jpg]


$check = $this->input->post('check');  
$total_rec = $_POST['total_rec'];

echo 'Check Value';

echo '<br><br>';

echo 'Total Recieve';


Check ValueArray ( [0] => 1 [1] => 2 [2] => 3 )

Total RecieveArray ( [0] => 10 [1] => 11 [2] => 12 )

But If I only inout the second textbox here's the output:

Check ValueArray ( [0] => 2 )

Total RecieveArray ( [0] => [1] => 11 [2] => )
Please help... T_____T