<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
function addRow(){
var table = document.getElementById("table");
var rows = table.rows.length;
var newRow = table.insertRow(rows-1);
var c1 = newRow.insertCell(0);
c1.innerHTML = "<input type=‘text‘ name=‘detail‘>";
var c2 = newRow.insertCell(1);
c2.innerHTML = "<input type=‘text‘ name=‘detail‘>";
var c3 = newRow.insertCell(2);
c3.innerHTML = "<input type=‘text‘ name=‘detail‘>";
var c4 = newRow.insertCell(3);
c4.innerHTML = "<input id=‘del‘ type=‘button‘ value=‘删除‘ onclick=‘del(this)‘><input id=‘save‘ type=‘button‘ value=‘保存‘ onclick=‘save()‘>"
}
function save(){
var details = document.getElementsByName("detail");
for(var i = 0;i<details.length;i++){
details[i].setAttribute("disabled","disabled");
}
var save = document.getElementById("save");
save.setAttribute("id","change");
save.setAttribute("value","修改");
save.setAttribute("onclick","update(this)");
}
function del(r){
var i = r.parentNode.parentNode.rowIndex;
document.getElementById("table").deleteRow(i);
}
function update(r){
var i = r.parentNode.parentNode.rowIndex;
var table = document.getElementById("table");
table.rows[i].cells[0].firstChild.disabled=false;
table.rows[i].cells[1].firstChild.disabled=false;
table.rows[i].cells[2].firstChild.disabled=false;
r.id="save";
r.value="保存";
r.setAttribute("onclick","save()");
}
</script>
</head>
<body>
<table id="table" border="1px" style="width: 600px;text-align: center;">
<thead>进销存管理系统--后台进货管理</thead>
<tr style="border: 1px solid black;">
<td >商品名称</td>
<td >数量</td>
<td >进价</td>
<td >操作</td>
</tr>
<tr>
<td><input type="text" value="雅芳Avon再生霜" disabled="disabled" name="detail"></td>
<td><input type="text" value="100" disabled="disabled" name="detail"></td>
<td><input type="text" value="¥8.5" disabled="disabled" name="detail"></td>
<td>
<input id="del" type="button" value="删除" onclick="del(this)">
<input id="change" type="button" value="修改" onclick="update(this)">
</td>
</tr>
<tr>
<td><input type="text" value="雅芳Avon再生霜" disabled="disabled" name="detail"></td>
<td><input type="text" value="100" disabled="disabled" name="detail"></td>
<td><input type="text" value="¥8.5" disabled="disabled" name="detail"></td>
<td>
<input id="del" type="button" value="删除" onclick="del(this)">
<input id="change" type="button" value="修改" onclick="update(this)">
</td>
</tr>
<tr>
<td><input type="text" value="雅芳Avon再生霜" disabled="disabled" name="detail"></td>
<td><input type="text" value="100" disabled="disabled" name="detail"></td>
<td><input type="text" value="¥8.5" disabled="disabled" name="detail"></td>
<td>
<input id="del" type="button" value="删除" onclick="del(this)">
<input id="change" type="button" value="修改" onclick="update(this)">
</td>
</tr>
<tr>
<td colspan="4"><input type="button" value="增加商品" onclick="addRow()"></td>
</tr>
</table>
</body>
</html>
订单管理 练习