Hi all,i'm trying to show updated data in existing html td.. For example i got column that show last modified datetime,then i want to update data again,the column will changed to current time without refreshing the page.These are my codes
views/order_home -
<script type="text/javascript" src="<?php echo base_url(); ?>js/jquery.js"></script>
-
<script type="text/javascript" src="<?php echo base_url(); ?>js/jquery.form.js"></script>
-
<script type="text/javascript">
-
// wait for the DOM to be loaded
-
$(document).ready(function()
-
{ $("#msg").hide();
-
$('#myform').ajaxForm(function()
-
{
-
var id = $('#id').val();
-
$.post("order/getOrder/", { 'id' : id },
-
function(data){
-
$('#modif').html(data.modified);
-
}, "json");
-
$("#msg").html("Berhasil update order").fadeIn(1500);
-
$("#msg").fadeOut(1500);
-
});
-
});
-
</script> <h1><?php echo $title;?></h1>
-
<?php
-
if ($this->session->flashdata('message')){
-
echo "<div class='message' name='msg' id='msg'>".$this->session->flashdata('message')."</div>";
-
}
-
echo "<div name='msg' class ='msg' id='msg'></div>";
-
//echo "<div class='message' name='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>Actions</th>\n";
-
echo "</tr>\n";
-
if (count($order)){
-
foreach ($order as $key => $list){
-
echo "<tr valign='top'>\n";
-
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:s ", $modifieddate);
-
echo "<td id='modif' name='modif'>".$modified."</td>\n";
-
$attributes = array('id' => 'myform');
-
echo form_open('admin/order/edit',$attributes);
-
echo "<td align='center'>".form_dropdown('status',$status,$list['status'])."</td>\n";
-
echo '<input type="hidden" id="id" name="id" value="'.$list['id'].'" />';
-
$data = array('name'=>'notif','id'=>'notif');
-
echo "<td align='center'>".form_checkbox($data)."<label for='update'>Notifikasi cust</label>".form_submit('submit','Update')."</td>\n";
-
echo "<td align='center'>";
-
echo anchor("admin/order/edit/".$list['no_order'],img(base_url().'/images/edit.jpg'));
-
echo " | ";
-
echo anchor("admin/order/delete/".$list['no_order'],img(base_url().'/images/delete.jpg'));
-
echo "</td>\n";
-
echo "</tr>\n";
-
echo form_close();
-
}
-
}
-
echo "</table>";
-
?>
-
controller/order -
function edit($no=0)
-
{
-
if ($this->input->post('id'))
-
{
-
if (isset($_REQUEST['notif']))
-
{
-
$this->input->post('status_order');
-
$result=$this->MOrder->updateOrder();
-
$this->email->from('admin@7com.cphoster.com','Admin');
-
$this->email->to('yonghan79@gmail.com');
-
$this->email->subject('Testing email class');
-
$this->email->message('Status order '.$status);
-
$this->email->send();
-
$this->session->set_flashdata('message','Berhasil update order');
-
redirect('admin/order/index','refresh');
-
}
-
else
-
{
-
$this->MOrder->updateOrder();
-
$this->session->set_flashdata('message','Berhasil update order');
-
redirect('admin/order/index','refresh');
-
}
-
}
-
}
-
-
function getOrder()
-
{
-
$no = $this->input->post('id');
-
$hasil=$this->MOrder->getOrder($no);
-
$array=array('modified'=>$hasil['modified']);
-
echo json_encode($array);
-
-
}
-
this is my testing site testing site
username : admin
password : admin
The issue is in the order page...Thanks a lot
5 6926
Line 12 seems to be where you're setting the time. What's the value of data.modified?
It's datetime acoder... -
# $modifieddate = strtotime($list['modified']);
-
# $modified = date("d-m-y H:i:s ", $modifieddate);
-
# echo "<td id='modif' name='modif'>".$modified."</td>\n";
-
If i update the first row,it works fine.But if i update the second row,the td doesn'r show the way it should be..Thanks...
Ah right, so it's just a formatting problem. What you can do is either use the Date object methods (get***) or split the modified (string) value to get the date/time separately, i.e. on the space character - see split(). Then split on the hyphen to get the date parts and swap them around.
If you want to avoid all that, try using some code like this.
Actually it's not a formatting problem acoder. ^_^ Praise God i got it working already..I should loop the form.. ^_^ Thanks for your help acoder.God bless you.. ^_^
You had the same ID multiple times which is not allowed. IDs must be unique, so the wrong element was being selected.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: N. Graves |
last post by:
Hello... thank you for your time.
I have a form that has a List box of equipotent records and a sub form
that will show the data of the equipment select from the list box.
Is it possible to...
|
by: jdi |
last post by:
Hello,
I have a seemingly basic question about ASP.NET. I would like to
create a page containing an image, which keeps swapping the url of the
image source, without refreshing the entire page. ...
|
by: nospamjac |
last post by:
Hi,
Is there a way to update the text of an asp:label on a webform without
refreshing the entire page? What is called by button clicks and other
events that refresh a webform control?
See the...
|
by: cguillot |
last post by:
Hello,
I have a web page that displays information from a SQL database and
this information can change frequently. Basically, a database entry is
made into a table every time a person enters or...
|
by: Jim Hammond |
last post by:
It would be udeful to be able to get the current on-screen values from a
FormView that is databound to an ObjectDataSource by using a callback instead
of a postback. For example:
public void...
|
by: PAUL |
last post by:
Hello,
I have 2 tables with a relationship set up in the dataset with vb
..net. I add a new record to the parent table then edit an existing child
record to have the new parent ID. However when I...
|
by: bhcob1 |
last post by:
Hey guys,
'Update or CancelUpdate without AddNew or Edit'
On my database i keep occasionly get this error when i try and edit a field, it is not everytime. It will be working fine and then this...
|
by: micmit |
last post by:
I wanted to avoid any HTML file creation , so initial HTML was formed as a string and assigned to DocumentText.
After that the aim was to manipulate with html using DOM .
It turned out...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |