CodeGuru Forums -
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic Newsletters VB Forums Developer.com


Newest CodeGuru.com Articles:

  • Installing SQL Server 2008
  • Writing UDFs for Firebird Embedded SQL Server
  • [Updated] Shutdown Manager
  • Building Windows Azure Cloud Service Applications with Azure Storage and the Azure SDK

  • Search CodeGuru:
     



    Go Back   CodeGuru Forums > Other Programming > AJAX
    FAQ Members List Calendar Search Today's Posts Mark Forums Read

    AJAX Post questions and discussions related to AJAX - Asynchronous javascript and XML.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1    
    Old October 31st, 2009, 06:12 AM
    yonghan yonghan is offline
    Junior Member
     
    Join Date: Jul 2008
    Posts: 3
    yonghan is an unknown quantity at this point (<10)
    change html table td value without refreshing

    Hi all,suppose i got two rows like this picture



    I'm trying to change the modified column value to current datetime without refreshing the page when i click the update button..The first row worked,the second doesn't work..Here is my codes

    views/order_home
    Code:
    <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 no_id=$('#no_id').val();
    		
    		$.post("getOrder/", { 'id' : no_id },
    		function(data){
    	$('#modif').html(data.modified);
    	}, "json");
    		
    		//nampilin di div message string yg ada di dalam html()
    		$("#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 "<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 "<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 ", $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";
    		$btn = array('id'=>'update','name'=>'update','value'=>'Update'); 
    		$data = array('name'=>'notif','id'=>'notif');
    		echo "<td align='center'>".form_checkbox($data)."<label for='update'>Notifikasi cust</label>".form_submit($btn)."</td>\n";
           	echo '<input type="hidden" id="no_id" name="no_id" value="'.$list['id'].'" />';
    		echo form_close();
    		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 "</table>";
    ?>
    controller/order
    Code:
    function edit($no=0)
    	{
    		if ($this->input->post('no_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();
    			//return $result;
    		    $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');
                }
    		}
    		else
    		{
    			//$id = $this->uri->segment(4);
    			$data['title'] = "Edit Order";
    			$data['main'] = 'admin/order_edit';
    			$data['order'] = $this->MOrder->getOrder($no);
    			$data['status']=$this->MOrder->getStatus();
    	        if (!count($data['order'])){
    				redirect('admin/order/index','refresh');
    			}
    			$this->load->vars($data);
    			$this->load->view('dashboard');
    	}
    	}
    	
    	//buat ambil data dari db menggunakan jquery n json
    	function getOrder()
    	{
    	$no=trim($this->input->post('id'));
    	$hasil=$this->MOrder->getOrder($no);
    	$datetime = strtotime($hasil['modified']);
    	$orderdate = date("d-m-y H:i ", $datetime);
    	$array=array('modified'=>$orderdate);
    	echo json_encode($array);			
    	}
    Are there anything wrong with my codes?What should i do?Thanks a lot...
    Reply With Quote
    Reply

    Bookmarks
    Go Back   CodeGuru Forums > Other Programming > AJAX


    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 02:17 AM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy


    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
    Copyright WebMediaBrands Inc. 2002-2009