Hi all,i got codes like this

$ ( "#msg").hide();
$ ( '#myform').ajaxForm(function()
$ .post("getOrder/", { 'id' : id },
$ ( '#modif').html(data.modified);
}, "json");
$ ( "#msg").html("Berhasil update order").fadeIn(1500);
$ ( "#msg").fadeOut(1500);

< ? php
echo "< div name='msg' class ='msg' id='msg'></ div>";
echo "< table border='1' cellspacing='0' cellpadding='3' width='100%' 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>id</ th>< th>Actions</ th>\n"; echo "</ tr>\n"; if (count($order)) {
foreach ($order as $key => $list)
echo form open('admin/order/edit',$attributes);
echo < td align='center'>".form
'echo input type="hidden" id="id" name="id" value="'.$list['id'].'" />';
$data = array('name'=>'notif','id'=>'notif');
echo "< td align='center'>".form checkbox($data). "
echo "< label for='update'>Notifikasi cust ".form
echo form_ close(); }

I try using 2 rows,when i check by using firebug and upon i click the second row update button,it return id=1 instead of 2.What should i do?Are there any mistakes in my codes?Thanks a lot... ^_^


  • Just as a note, using a template or templating system is a must, separates your business logic and your display logic, will make bugs much more transparent. Tchalvak almost 10 years ago

1 answer


Hmmm, I'd guess that you're you're counting your array with ordinal numbers, i.e. starting with 0, 1, 2, 3, 4 instead of 1, 2, 3, 4, 5.

So perhaps just instead of:

'echo input type="hidden" id="id" name="id" value="'.$list['id'].'" />'; 

make it:

'echo input type="hidden" id="id" name="id" value="'.($list['id']+1).'" />'; 

Also, If I were you, I'd avoid using just "id" as an identifier, since that name is vague (css id, the many different ids you need to use in a relational database, etc).

Answered almost 10 years ago by Tchalvak
  • Thanks Tchalvak..I'll try it first... handoyo almost 10 years ago
  • Hi,i've tried it.Yet it doesn't work..Also i changed the id="id" to id="no_id".. Thanks a lot... handoyo almost 10 years ago