javascript实现增删改查

<formaction=""name="form"method="post"><tablewidth="548"height="108"cellpadding="2"id... <form action="" name="form" method="post">
<table width="548" height="108" cellpadding="2" id="tableForm" border="1" onchange="tableDisplay()">
<tr >
<td colspan="5">姓名:
<label>
<input type="text" name="txtName" />
<input type="button" name="btnSearch" value="查询" onclick="btnSearchOnClick()" />
</label></td>
</tr>
<tr>
<th>姓名</th>
<th>年龄</th>
<th>日期</th>
<th>地区</th>
<th>所属市</th>
</tr>
<tr align="center" id="row1" onClick="rowOnClick(1)">
<td>李四</td>
<td>23</td>
<td>1982-05-01</td>
<td>山东</td>
<td>济南</td>
</tr>
<tr align="center" id="row2" onClick="rowOnClick(2)">
<td>张三</td>
<td>20</td>
<td>1985-05-01</td>
<td>台湾</td>
<td>台北</td>
</tr>
</table>
<table width="548" height="21" cellspacing="2" id="tableUnder">
<tr>
<td width="46%">
<label>
<input type="button" name="btnAdd" value="添加" onclick="btnAddOnclick()"/>
</label>
</td>
<td width="13%"> <input type="button" name="btnAdd" value="修改" /></td>
<td width="13%"> <input type="button" name="btnAdd" value="删除" onclick="btnDeleteOnClick()" /> </td>
<td width="*"> <input type="button" name="btnAdd" value="增加薪资栏位" onclick="AppendTr();" /></td>

</tr>
</table>
展开
 我来答
raymonlu
推荐于2016-09-28 · TA获得超过943个赞
知道小有建树答主
回答量:792
采纳率:0%
帮助的人:759万
展开全部
使用XMLHttpRequest
下面给一共例子桥宴
function commitEdit(type, val, id) {
var http_request = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
http_request.overrideMimeType('text/xml');
}
} else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!http_request) {
alert('Giving up :( Cannot create an XMLHTTP instance');
return false;
}
var sendData = "val=" + val + "&type=" + type + "&id=" + id;
http_request.onreadystatechange = function() {alertContents(http_request, type);};
url = "listUpdate.jsp";
http_request.open('POST', url, true);
http_request.setRequestHeader("Content-Length", sendData.length);
http_request.setRequestHeader("CONTENT-TYPE", "application/x-www-form-urlencoded");
http_request.send(sendData);
}

function alertContents(http_request, type) {
if (http_request.readyState == 4) {
var resTxt = trimString1(http_request.responseText);
if (resTxt == "-1") {
alert("内容不健康,添加错误!");
return;
}
if (type == "label"敏蔽银) {
document.getElementById("listLabel").innerHTML = resTxt;
document.getElementById("addLabelLink").innerHTML = "修改并则标签";
} else if (type == "addLabel") {
document.getElementById("listLabel").innerHTML = resTxt;
document.getElementById("listLabelTr").style.display = 'block';
document.getElementById("addLabelLink").innerHTML = "修改标签";
document.getElementById("addLabelLink").href = "javascript:chngLabel();";
} else if (type == "listComment") {
document.getElementById("listReviewContext").innerHTML = resTxt;
} else if (type == "addFavorite") {
alert(resTxt);
}
}
}
本回答被提问者和网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式