首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

新手请问:关于jquery对表格的操作

2013-07-09 
新手请教:关于jquery对表格的操作我有一个表格,如何通过Jquery点击表格中的“完成”小图标,1.执行ajax在数据

新手请教:关于jquery对表格的操作
我有一个表格,
如何通过Jquery点击表格中的“完成”小图标,
1.执行ajax在数据库中更改订单状态,
2.并使本行中“订单状态”的内容改为“完成”?

附图1:
新手请问:关于jquery对表格的操作


附表格代码:(表格ID="tab")


<table  width="80%" border="0" align="center" cellspacing="1" class="xqcd" style="border:1px solid #09C;" id="tab">
<form name="form1">
  <tr style="background-image:url(image/c1.jpg)">
    <th height="40"><font color="#FFFFFF" size="3">订单编号</font></th>
    <th><font color="#FFFFFF" size="3">订单状态</font></th>
    <th><font color="#FFFFFF" size="3">客户姓名</font></th>
    <th><font color="#FFFFFF" size="3">联系电话</font></th>
    <th><font color="#FFFFFF" size="3">来电号码</font></th>
    <th><font color="#FFFFFF" size="3">来电时间</font></th>
    <th><font color="#FFFFFF" size="3">配送人</font></th>
    <th><font color="#FFFFFF" size="3">转派</font></th>
    <th><font color="#FFFFFF" size="3">配送电话</font></th>
    <th><font color="#FFFFFF" size="3">详情</font></th>
    <th><font color="#FFFFFF" size="3">催办</font></th>
    <th><font color="#FFFFFF" size="3">完成</font></th>
    </tr>
    
<?    
$SQL = "select a.* from script a";
$query=mysql_query($SQL);
while($rs = mysql_fetch_array($query)){    
?>
  <tr bgcolor="">
    <td height="40" align="center"><span id="hold_stockCode"><?=$rs[script_id]?></span></td>
    <td align="center"><span id="wei"><?=$rs[wei]?></span></td>
    <td align="center"><?=$rs[call_name]?></td>
    <td><?=$rs[call_tel]?></td>
    <td><?=$rs[call_number]?></td>
    <td><?=$rs[stime]?></td>
    <td><?=$rs[salesman]?></td>
    <td><a href="#"><img src="image/xiugai.png" width="36" height="38" border="0" /></a></td>
    <td><?=$rs[sales_tel]?></td>
    <td><a href="#"><img src="image/12O264103920-1D6339.gif" width="24" height="24" border="0" /></a></td>
    <td><a href="#"><img src="image/duanxin.png" width="36" height="38" border="0" /></a></td>
    <td><a href="#" class="wancheng"><img src="image/wancheng.png" width="36" height="38" border="0" /></a></td>
    </tr>
    
    <? }?>

  </form>


</table>




我自己写的Jqurey,由于是新学,思绪有点乱
现在已经可以找到“完成”的那个图标,
问题是点击后,怎样将ajax中的html返回到“订单状态”的那个格子里?


$(function(){

   $("#tab tr td a.wancheng").click(function(){//单击某个图标
  //响应到下单事件中
   alert($(this).parent().parent().find('span[id="hold_stockCode"]').text());
   
$.post("script_wancheng.php",{script_id:$(this).parent().parent().find('span[id="hold_stockCode"]').text()},function(date){
$("这里怎么确定本行中【订单状态】的那个TD?").html(date);
 });

   
   })
   
})


[解决办法]
$(function(){
   $("#tab tr td a.wancheng").click(function(){//单击某个图标
  //响应到下单事件中
        var tr = $(this).parent().parent();
        var id = tr.find('span[id="hold_stockCode"]').text();
        var statusTd = tr.find('span[id="wei"]');
        $.post("script_wancheng.php",{script_id:id },function(date){
            statusTd .html(date);
        });
   })
})

热点排行