http://jsbin.com/ezecun/edit#javascript,html
我必须这样写,因为它是动态制作的,下面列出了实际代码。我在 jsbin 中对其进行了一些简化。基本上,用不可用的框的值更新数组需要很长时间。
谢谢参观。
代码:php
echo "<label style='float:left'>Comments: </label> <textarea onKeyUp=\"editItemInCart(this.value,'comments',".$itemNum.")\" onChange=\"editItemInCart(this.value,'comments',".$itemNum.")\" >".$cart['comments']."</textarea><br />";
javascript
function editItemInCart(newValue,fieldName,itemNum) {
jQuery.ajax({
type:"POST",
url: "editItem.html",
data: "newvalue=" + newValue + "&fieldname=" + fieldName + "&itemNum=" + itemNum,
})
//alert(newValue + fieldName + itemNum);
}