Let me do the work first. If 1 is the pre-editing effect, figure 2 is the effect of clicking on "Modify Inventory". HTML and CSS have been made, but JavaScript is not understood. Modified data directly through the background PHP modified to MySQL, if successful, return the data directly to the inventory TD cell.
Then there is my HTML code.
3308 3.97 M³ 2950.00 元 2013-05-21 14:36:20 保存修改
Ask the brothers to give a detailed answer, really do not understand JavaScript ah, the entire page is poor this one function realized. In addition, such a table has a long column, I can use the PHP loop to generate Dynamic HTML tag ID.
Thanks Thank you!
Reply content:
Let me do the work first. If 1 is the pre-editing effect, figure 2 is the effect of clicking on "Modify Inventory". HTML and CSS have been made, but JavaScript is not understood. Modified data directly through the background PHP modified to MySQL, if successful, return the data directly to the inventory TD cell.
Then there is my HTML code.
3308 3.97 M³ 2950.00 元 2013-05-21 14:36:20 保存修改
Ask the brothers to give a detailed answer, really do not understand JavaScript ah, the entire page is poor this one function realized. In addition, such a table has a long column, I can use the PHP loop to generate Dynamic HTML tag ID.
Thanks Thank you!
The above answer, I did not adopt the answer, it is my level is limited, not modified. The problem was also raised in Php100, which was soon resolved. The following php100 the answer, and attach links to facilitate others.
<title>Untitled Document</title>
| 3308 |
3.97 M3 |
2950.00 Yuan |
2013-05-21 14:36:20 |
0 units in Stock |
Modify Inventory |
| 3308 |
3.97 M3 |
2950.00 Yuan |
2013-05-21 14:36:20 |
0 units in Stock |
Modify Inventory |
Above is the HTML page, below is the PHP
'错误!', 'status' => FALSE, 'num' => 0);if(isset($_POST['id']) && isset($_POST['num'])){ if(is_numeric($_POST['id']) && is_numeric($_POST['num'])){ $id = (int)$_POST['id']; $num = (int)$_POST['num']; $r['msg'] = '修改成功!'; $r['num'] = $num; $r['status'] = TRUE; }else{ $r['msg'] = '错误![2]'; }}else{ $r['msg'] = '错误![1]';}echo json_encode($r);?>
$(document).ready(function() {//为每一个具有相同id=cartUpdate 的 添加click事件$("#cartUpdate").live("click",function(){ var text=$(this).text(); if(text=="修改数量"){ var count = $(this).parent().prev().text(); $(this).parent().prev().html(""); $(this).text("确定"); }else if(text=="确定"){ var count2 = $(this).parent().prev().children().val(); var id = $(this).parent().prev().prev().prev().prev().text(); $.post("/cart/update", { "productId" : id,"count":count2 }, function(data) { if(data=="ok"){ $("#p" + id).next().next().next().text(count2); $("#p" + id).nextAll().find("button").text("修改数量"); }else{ alert("修改失败"); } }); }});