473,324 Members | 2,501 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

update html table td without refreshing

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
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript" src="<?php echo base_url(); ?>js/jquery.js"></script>
  2. <script type="text/javascript" src="<?php echo base_url(); ?>js/jquery.form.js"></script>
  3. <script type="text/javascript"> 
  4. // wait for the DOM to be loaded 
  5. $(document).ready(function() 
  6. { $("#msg").hide();
  7. $('#myform').ajaxForm(function()
  8. {
  9. var id = $('#id').val();
  10. $.post("order/getOrder/", { 'id' : id },
  11. function(data){
  12. $('#modif').html(data.modified);
  13. }, "json");
  14. $("#msg").html("Berhasil update order").fadeIn(1500);
  15. $("#msg").fadeOut(1500);
  16. });
  17. }); 
  18. </script> <h1><?php echo $title;?></h1>
  19. <?php
  20. if ($this->session->flashdata('message')){
  21. echo "<div class='message' name='msg' id='msg'>".$this->session->flashdata('message')."</div>";
  22. }
  23. echo "<div name='msg' class ='msg' id='msg'></div>";
  24. //echo "<div class='message' name='msg' id='msg'></div>";
  25.  
  26. echo "<table border='1' cellspacing='0' cellpadding='3' width='100%' id='order_home' name='order_home'>\n";
  27. echo "<tr valign='top'>\n";
  28. 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";
  29. echo "</tr>\n";
  30. if (count($order)){
  31. foreach ($order as $key => $list){
  32. echo "<tr valign='top'>\n";
  33. echo "<td>".anchor("admin/order/detail/".$list['no_order'],$list['no_order'])."</td>\n";
  34. echo "<td>".$list['custid']."</td>\n";
  35. $datetime = strtotime($list['tgl_pesan']);
  36. $orderdate = date("d-m-y H:i ", $datetime);
  37. echo "<td>".$orderdate."</td>\n";
  38. $modifieddate = strtotime($list['modified']);
  39. $modified = date("d-m-y H:i:s ", $modifieddate);
  40. echo "<td id='modif' name='modif'>".$modified."</td>\n";
  41. $attributes = array('id' => 'myform');
  42. echo form_open('admin/order/edit',$attributes);
  43. echo "<td align='center'>".form_dropdown('status',$status,$list['status'])."</td>\n";
  44. echo '<input type="hidden" id="id" name="id" value="'.$list['id'].'" />';
  45. $data = array('name'=>'notif','id'=>'notif');
  46. echo "<td align='center'>".form_checkbox($data)."<label for='update'>Notifikasi cust</label>".form_submit('submit','Update')."</td>\n";
  47. echo "<td align='center'>";
  48. echo anchor("admin/order/edit/".$list['no_order'],img(base_url().'/images/edit.jpg'));
  49. echo " | ";
  50. echo anchor("admin/order/delete/".$list['no_order'],img(base_url().'/images/delete.jpg'));
  51. echo "</td>\n";
  52. echo "</tr>\n";
  53. echo form_close();
  54. }
  55. }
  56. echo "</table>";
  57. ?>
  58.  
controller/order
Expand|Select|Wrap|Line Numbers
  1. function edit($no=0)
  2. {
  3. if ($this->input->post('id'))
  4. {
  5. if (isset($_REQUEST['notif']))
  6. {
  7. $this->input->post('status_order');
  8. $result=$this->MOrder->updateOrder();
  9. $this->email->from('admin@7com.cphoster.com','Admin');
  10. $this->email->to('yonghan79@gmail.com');
  11. $this->email->subject('Testing email class');
  12. $this->email->message('Status order '.$status);
  13. $this->email->send();
  14. $this->session->set_flashdata('message','Berhasil update order');
  15. redirect('admin/order/index','refresh');
  16. }
  17. else
  18. {
  19. $this->MOrder->updateOrder();
  20. $this->session->set_flashdata('message','Berhasil update order');
  21. redirect('admin/order/index','refresh');
  22. }
  23. }
  24. }
  25.  
  26. function getOrder()
  27. {
  28. $no = $this->input->post('id');
  29. $hasil=$this->MOrder->getOrder($no);
  30. $array=array('modified'=>$hasil['modified']);
  31. echo json_encode($array);            
  32.  
  33.     }
  34.  
this is my testing site

testing site
username : admin
password : admin

The issue is in the order page...Thanks a lot
Oct 30 '09 #1
5 6926
acoder
16,027 Expert Mod 8TB
Line 12 seems to be where you're setting the time. What's the value of data.modified?
Nov 1 '09 #2
It's datetime acoder...
Expand|Select|Wrap|Line Numbers
  1. # $modifieddate = strtotime($list['modified']);
  2. # $modified = date("d-m-y H:i:s ", $modifieddate);
  3. # echo "<td id='modif' name='modif'>".$modified."</td>\n";
  4.  
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...
Nov 2 '09 #3
acoder
16,027 Expert Mod 8TB
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.
Nov 2 '09 #4
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.. ^_^
Nov 2 '09 #5
acoder
16,027 Expert Mod 8TB
You had the same ID multiple times which is not allowed. IDs must be unique, so the wrong element was being selected.
Nov 8 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
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...
2
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. ...
1
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...
1
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...
4
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...
5
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...
9
bhcob1
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...
0
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...
0
isladogs
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...
1
isladogs
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...
0
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...
1
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)...
1
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
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....
0
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
0
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.