tempUpdate

 

<tr style="cursor: pointer; color: maroon" align="center">
        <td onclick="modify(<%=item.getBook().getId()%>,this)"><%=item.getNum()%></td>
	<td style="color: green">
		<a href="DelFromCartServlet?id=<%=item.getBook().getId()%>">删除</a>
	</td>
</tr>

   <script type="text/javascript">

window.onload = function() {
	var obj = document.getElementsByTagName("TR")
	for ( var i = 0; i < obj.length; i++) {
		obj[i].onmouseover = function() {
			this.style.backgroundColor = "PINK"
		}
		obj[i].onmouseout = function() {
			this.style.backgroundColor = "";
		}
		if (i % 2 == 0) {
			obj[i].className = "line1";
		} else {
			obj[i].className = "line2";
		}
	}

}
</script>
		<script type="text/javascript">
function modify(id, td) {
	var num = td.innerHTML;

	td.innerHTML = "";

	//隐藏域
	var txtId = document.createElement("INPUT");
	txtId.size = "2";
	txtId.type = "hidden";
	txtId.value = id;

	td.appendChild(txtId);

	//文本框
	var txt = document.createElement("INPUT");
	txt.size = "10";
	txt.type = "text";
	txt.style.textAlign = "center";
	txt.style.backgroundColor = "YELLOW";
	txt.value = num;

	txt.onblur = function() {
		//doModifyNum.jsp
		var num = this.value;
		var id = this.parentNode.firstChild.value;
		//alert(this.parentNode.firstChild.value);
		if (num > 0) {
			location.href = "ModifyBookNumServlet?id=" + id + "&num=" + num;
		} else {
			alert('请输入整数!');
			return;
		}
	}

	td.appendChild(txt);

	td.onclick = null;
	txt.focus();
}
</script>
 

 

你可能感兴趣的:(update)