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 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?