[code="ruby"]
httpobj=getHTTPObject(); function getdeptxml() { if(httpobj) { httpobj.open("POST","departmentinfo.asp",true); httpobj.onreadystatechange=gotResult; httpobj.setRequestHeader('Content-Type','application/x-www-form-urlencoded;charset=gb2312'); httpobj.send(null); } } function gotResult() { if (httpobj.readyState==4) { if(httpobj.status==200) { var xmldoc=new ActiveXObject("Microsoft.XMLDOM"); xmldoc.async=false; xmldoc.loadXML(httpobj.responseText); cleartable(dept_table); var i,tr,td; i=0; while(xmldoc.documentElement.childNodes.item(i)!=null) { tr=dept_table.insertRow(); td=tr.insertCell(); td.innerHTML=xmldoc.documentElement.childNodes.item(i).childNodes.item(0).text; td=tr.insertCell(); td.innerHTML="<input name=cell"+i+"1 type=text value="+unescape(xmldoc.documentElement.childNodes.item(i).chidNodes.item(1).text)+">"; td=tr.insertCell(); td.innerHTML="<input name=cell"+i+"2 type=text value="+unescape(xmldoc.documentElement.childNodes.item(i).chidNodes.item(2).text)+">"; td=tr.insertCell(); td.innerHTML="<input type=button value=修改 onclick=editdept("+i+","+(xmldoc.documentElement.childNodes.item(i).nodeName).substr(3)+")>"; td=tr.insertCell(); td.innerHTML="<input type=button value=删除 onclick=deletedept("+(xmldoc.documentElement.childNodes.item(i).nodeName).substr(3)+")>"; i=i+1; } } } } function cleartable(obj) { for(var k=obj.rows.length-1;k>=1;k--) obj.deleteRow(k); } function editdept(i,id) { if(document.getElementById("cell"+i+"1").value=="") { alert("部门名称不能为空"); return; } if(httpobj) { httpobj.open("POST","edit_department_do.asp",true); httpobj.onreadystatechange=gotResult_edit; httpobj.setRequestHeader('Content-Type','application/x-www-form-urlencoded;charset=gb2312'); param="id="+id+"&deptname="+escape(document.getElementById("cell"+i+"1").value)+"&remark="+escape(document.getElementById("cell"+i+"2").value); httpobj.send(param); } } function gotResult_edit() { if(httpobj.readyState==4) { if(httpobj.status==200) { if(httpobj.responseText=="success") window.alert("数据修改成功"); else if(httpobj.responseText=="failed") window.alert("部门名称发生重复"); } } } function deletedept(id) { if(httpobj) { httpobj.open("POST","del_department_do.asp",true); httpobj.onreadystatechange=gotResult_del; httpobj.setRequestHeader('Content-Type','application/x-www-form-urlencoded;charset=gb2312'); param="id="+id; httpobj.send(param); } } function gotResult_del() { if(httpobj.readyState==4) { if(httpobj.status==200) { if(httpobj.responseText=="success") { window.alert("数据删除成功"); getdeptxml(); } else window.alert("数据删除失败"); } } } function getHTTPObject() { var xmlhttp=false; if(window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); if(xmlhttp.overrideMimeType) { xmlhttp.overrideMimeType('text/xml'); } } else { try { xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch(E) { xmlhttp=false; } } } return xmlhttp; }序号 | 部门名称 | 描述 | 修改 | 删除 |
[/code]
出现什么问题嘛,没说清楚?