Welcome Guest, Not a member yet? Register   Sign In
update field modified value in table
#11

[eluser]handoyo[/eluser]
If i write like this

Code:
//echo "</tr>\n";
$attributes = array('id' => 'myform');
echo form_open('admin/order/edit',$attributes);
//echo "&lt;form&gt;";
    $i = 0;
    foreach ($order as $key => $list)
    {
    
   echo '<table><tr><td>';
   echo '  <th>No Order</th>\n<th>No Cust</th><th>Tgl Pesan</th><th>Modified</th><th>Status</th><th>Update</th><th>Actions</th>\n"';
/* PUT OTHER DATA IN THERE COLUMNS */
    echo '</td>';
    echo '<td id="modif_'.$i.'">';
               /* YOUR UPDATES CAN GO HERE */
    echo '</td><td>';
                /*Button calling javascript with $i as Row number*/
    echo '</td></tr></table>';
    $i++;
    }
echo form_close();

it shows me multiple table cause it loops,should i put the table before the form_open()? Thanks.. ^_^
#12

[eluser]@rno[/eluser]
These are ment as the column(s) where you put your order number, customer etc.
#13

[eluser]handoyo[/eluser]
Sorry Arno,does this codes are correct?

Code:
echo "<table border='1' cellspacing='0' cellpadding='3' width='600' id='order_home' name='order_home'>\n";
echo "<tr valign='top'>\n";
echo "<th>No Order</th>\n<th>No Cust</th><th>Tgl Pesan</th><th>Modified</th><th>Status</th><th>Update</th><th>Actions</th>\n";
echo "</tr>\n";
$attributes = array('id' => 'myform');
echo form_open('admin/order/edit',$attributes);
//echo "&lt;form&gt;";
    $i = 0;
    foreach ($order as $key => $list)
    {
    echo '<tr>';
    echo "<td>".anchor("admin/order/detail/".$list['no_order'],$list['no_order'])."</td>\n";
        echo "<td>".$list['custid']."</td>\n";
        $datetime = strtotime($list['tgl_pesan']);
        $orderdate = date("d-m-y H:i ", $datetime);
        echo "<td>".$orderdate."</td>\n";
        $modifieddate = strtotime($list['modified']);
        $modified = date("d-m-y H:i ", $modifieddate);
        
    /* PUT OTHER DATA IN THERE COLUMNS */
       echo '<td id="modif_'.$i.'" name="modif">'.$modified."</td>\n";
               /* YOUR UPDATES CAN GO HERE */
    echo "<td align='center'>".form_dropdown('status',$status,$list['status'])."</td>\n";
        echo '&lt;input type="hidden" id="id" name="id" value="'.$list['id'].'" /&gt;';
        //echo form_hidden('id',$list['id']);
        echo form_hidden('status_order',$list['status']);
        $data = array('name'=>'notif','id'=>'notif');
        $button=array('name'=>'submit','id'=>'submit_button','value'=>'Update');
        echo "<td align='center'>".form_checkbox($data)."<label for='update'>Notifikasi cust</label>".form_submit($button)."</td>\n";
        echo "<td align='center'>";
        //echo anchor('admin/kategori/edit/'.$list['id'],'edit');
        echo anchor("admin/order/edit/".$list['no_order'],img(base_url().'/images/edit.jpg'));
        echo " | ";
        //echo anchor('admin/kategori/delete/'.$list['id'],'delete');
        echo anchor("admin/order/delete/".$list['no_order'],img(base_url().'/images/delete.jpg'));
        echo "</td>\n";          
    echo '</td><td>';
                /*Button calling javascript with $i as Row number*/
    echo '</td></tr>';
    $i++;
    }
echo form_close();

Thanks...
#14

[eluser]@rno[/eluser]
Almost.. Smile

This:
Code:
echo "<table border='1' cellspacing='0' cellpadding='3' width='600' id='order_home' name='order_home'>\n";
echo "<tr valign='top'>\n";
echo "<th>No Order</th>\n<th>No Cust</th><th>Tgl Pesan</th><th>Modified</th><th>Status</th><th>Update</th><th>Actions</th>\n";
echo "</tr>\n";

Should be inside the form, so after this:

Code:
$attributes = array('id' => 'myform');
echo form_open('admin/order/edit',$attributes);

And just before this:

Code:
echo form_close();

you should put this
Code:
</table>

G'd luck!

Arno
#15

[eluser]handoyo[/eluser]
Is it like this?

Code:
$attributes = array('id' => 'myform');
echo form_open('admin/order/edit',$attributes);
echo "<table border='1' cellspacing='0' cellpadding='3' width='600' id='order_home' name='order_home'>\n";
echo "<tr valign='top'>\n";
echo "<th>No Order</th>\n<th>No Cust</th><th>Tgl Pesan</th><th>Modified</th><th>Status</th><th>Update</th><th>Actions</th>\n";
echo "</tr>\n";

$i = 0;

foreach ($order as $key => $list)
{
    echo '<tr>';
    echo "<td>".anchor("admin/order/detail/".$list['no_order'],$list['no_order'])."</td>\n";
    echo "<td>".$list['custid']."</td>\n";
    $datetime = strtotime($list['tgl_pesan']);
    $orderdate = date("d-m-y H:i ", $datetime);
    echo "<td>".$orderdate."</td>\n";
    $modifieddate = strtotime($list['modified']);
    $modified = date("d-m-y H:i ", $modifieddate);
    
    /* PUT OTHER DATA IN THERE COLUMNS */
    echo '<td id="modif_'.$i.'" name="modif">'.$modified."</td>\n";
    /* YOUR UPDATES CAN GO HERE */
    echo "<td align='center'>".form_dropdown('status',$status,$list['status'])."</td>\n";
    echo '&lt;input type="hidden" id="id" name="id" value="'.$list['id'].'" /&gt;';
    //echo form_hidden('id',$list['id']);
    echo form_hidden('status_order',$list['status']);
    $data = array('name'=>'notif','id'=>'notif');
    $button=array('name'=>'submit','id'=>'submit_button','value'=>'Update');
    echo "<td align='center'>".form_checkbox($data)."<label for='update'>Notifikasi cust</label>".form_submit($button)."</td>\n";
    echo "<td align='center'>";
    //echo anchor('admin/kategori/edit/'.$list['id'],'edit');
    echo anchor("admin/order/edit/".$list['no_order'],img(base_url().'/images/edit.jpg'));
    echo " | ";
    //echo anchor('admin/kategori/delete/'.$list['id'],'delete');
    echo anchor("admin/order/delete/".$list['no_order'],img(base_url().'/images/delete.jpg'));
    echo "</td>\n";          
    echo '</td><td>';
    /*Button calling javascript with $i as Row number*/
    echo '</td></tr>';
    $i++;    
}
echo '</table>';
echo form_close();

By the way i have an error which says that i is not defined in

Code:
$('#modif_'+i).html(data.modified);

and also it only change the second row not the first,the first row and the second row data are also updated..Hehehe..

Would you mind to take a look at my testing site here?The order page..So you can see the problems..

testing site
username :admin
password :admin

God bless you for your kindness..And sorry to bother you.. ^_^
#16

[eluser]@rno[/eluser]
Code:
$('#modif_'+i).html(data.modified);

was just a sample.
From your row, when updating data, you should call a javascript function, with a parameter to indicate wich row the call came from. This parameter can than be stored inside the javascript function and be used on callback to update the correct row.

Regards,
Arno
#17

[eluser]handoyo[/eluser]
Ok...i'll try it..Thanks a lot.. ^_^




Theme © iAndrew 2016 - Forum software by © MyBB