douzhang2092 2011-01-10 12:46
浏览 288
已采纳

如何添加动态参数

the jquery plugin that im using is this http://code.google.com/p/jquery-in-place-editor/

if i have a table like this

<table>
<thead>
<tr>
<th>id</th>
<th>first name </th>
<th>last name </th>
</tr>
</thead>

<tbody>
<tr>
<td class="id">1</td>
<td class="fname">sarmen</td>
<td class="lname">mikey</td>
</tr>

<tr>
<td class="id">2</td>
<td class="fname">john</td>
<td class="lname">angelo</td>
</tr>

<tr>
<td class="id">3</td>
<td class="fname">sarmen</td>
<td class="lname">grande</td>
</tr>
</tbody>
</table>

and my js looked something like this

$("td.fname").editInPlace({
    url: 'ajax.php',
    params: '',
    show_buttons: true          
});

then lets say i click on the first record to edit it which is fname of sarmen. how can i pass a param that only accociates id 1 ? because if i do a query of lets say

"update tbl_users set fname = '$_POST['update_value']' where fname = '$_POST['original_html']'"

(note: im just showing an example so no need to clean posts if that was bothering you :) )

if i run this query the fname of sarmen will update in two records rather than one. How can i only update to id of 1 being to update only one record.

  • 写回答

2条回答 默认 最新

  • dthy81285 2011-01-10 13:34
    关注
    $("table tr").each(function(i, el) { 
    
       var tdId = $(el).find("td.id");
    
       $(this).find("td.fname".editInPlace({
           url: 'ajax.php',
           params: 'id=' + $(tdId).text(),
           show_buttons: true              
        });
    
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路