之前有发过一个php的,http://www.corange.cn/archives/2010/04/3576.html 
这两天又研究了一个,这个也是亲自测试过的 
html部分 
<Tr> 
<Td width="17" class="catid"><?php echo $row['bigclassid']?></Td> 
<Td width="133" ><span class="listorder" title="点击修改"><?php echo $row['sort']?></span></Td> 
</Tr> 
注意上面第一列一定要放在第一列,就是id那一列 
js部分 
<script> 
$('.listorder').click(function(e){ 
var catid = $(this).parent().siblings("td:eq(0)").text();//获取同一行上 第一列中的id值 
var listorder_now_text = $(this).text();//获取listorder中的内容 先保存起来 
$(this).text("");//设置内容为空 
var list_form = '<input type="text" value="'+listorder_now_text+'" size=2 class="listorder_input" />' ; 
$(this).parent().append(list_form); //插入 input框 
$(".listorder_input").focus(); 
//自定义一个div 提示修改中 
var loading = '<div id="loading"><img src="loading.gif" alt="修改中..." width="20" /></div>'; 
$(this).parent().append(loading); 
$('#loading') 
.css({ 
"color" : "red" , 
"display" : "none" 
}) 
//定义ajax的全局事件 
$(this).ajaxStart(function(){ 
$('#loading').show(); 
}) 
$(this).ajaxStop(function(){ 
$('#loading').remove(); 
}) 
$(".listorder_input").blur(function(){ 
var thislist = $(this).siblings(); //取得同级的标签 即 修改后需要显示的 listorder 
$.post("update_bigclassname_3.php",{ 
action : "mod_listorder", 
catid : catid , 
listorder : $(this).attr("value") 
} , function(data, textStatus){ 
$(thislist).text(data); 
} 
);//end .post 
$(this).remove(); 
})//end function blur 
})// end function click 
</script> 
更新部分就是普通文件, 
<?php 
mysql_select_db($database_lr, $lr); 
$bigclassid = trim($_REQUEST['catid']); 
$sort = trim($_REQUEST['listorder']); 
$update_sql = "update bigclass set sort='$sort' where bigclassid='$bigclassid'"; 
$result = mysql_query($update_sql); 
echo $sort; 
?> 
只要注意到上面那个echo $sort;就是更新完毕后传递的值 
同样要用到jquery,请自己下载后调试 
这个感觉比之前那个效果更好,当然看你自己喜欢哪个 
原文地址:http://www.corange.cn/archives/2010/04/3584.html
 
                    
                     
                    
                 
                    
                 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号