如何添加动态参数
the jquery plugin that im using is this http://code.google.com/p/jquery-in-place-editor/
我正在使用的jquery插件是这个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
我的js看起来像这样
$("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
然后让我说我点击第一条记录来编辑它,这是sarmen的fname。我怎样才能通过一个只能跟踪id 1的param?因为如果我做一个查询,让我们说
"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.
如果我运行此查询,sarmen的fname将更新为两个记录而不是一个。我怎样才能更新为1的id只更新一条记录。
2 个解决方案
#1
1
$("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
});
});
更多相关文章
- weiphp插件开发注意
- 如何将Composer中的CakePHP插件安装到app / Plugin中
- jQuery通过igorescobar jQuery掩码插件验证电话号码输入。
- Javascript语法中null与“”的误写导致长期困扰的问题终于解决了
- 记12306货运系统“抢订空车”插件的编写--订车流程梳理
- 超全超实用的Javascript类库和jQuery插件大全之一:图片,地图和图形
- 高性能JavaScript代码高亮插件
- javascript-cropper插件翻译笔记
- VS2010常用插件介绍之Javascript插件