ajax实现表格输入效果

来源:互联网 发布:天津办公软件培训 编辑:程序博客网 时间:2024/05/01 12:30
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=
"http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv=
"Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language=
"javascript1.2">
//返回值
var text=
"";
function send_request_(id_,remak)
{
//请求中文乱码必须解码两次
remak=encodeURI(encodeURI(remak));
http_request = new ActiveXObject(
"Microsoft.XMLHTTP");
if(!http_request){
return false;
}

http_request.onreadystatechange = processRequest;

http_request.open(
"post","http://localhost:8080/job/jobEntMemberManage/EnterprisesUI/resume/BeiZhu.action?id="+id_+"&Remark="+remak, false);

http_request.send(
"post");

return false;
}

function processRequest(){

if(http_request.readyState==4){
if(http_request.status==200){
//页面正常可以处理返回信息
text=http_request.responseText;
}else{
alert(
"对不起操作有误!");
}
}else{
//请等待
}
}

function dis(id_){

document.getElementById(id_).style.display =
"block";
document.getElementById(id_+
"_").style.display ="none";
document.getElementById(id_+
"_remark").focus();

document.getElementById(id_).style.backgroundColor=
"#ccc";
return false;

}

function dis2(id_){
//alert(id_);
document.getElementById(id_).style.display =
"none";
document.getElementById(id_+
"_").style.display ="block";
//alert(1);
if(document.getElementById(id_+
"_").innerHTML==document.getElementById(id_+"_remark").value)
{
return false;
}
alert(document.getElementById(id_+
"_remark").value);
send_request_(id_,document.getElementById(id_+
"_remark").value);
//alert(text);
if(text==
"2")
{
alert(
"添加说明失败!");
return false;
}

    document.getElementById(id_+
"_").innerHTML=document.getElementById(id_+"_remark").value;

return false;

}
</script>
</head>

<body>

    <span onClick=
"dis('100560')">
  <DIV id=100560_ style=
"WORD-BREAK: break-all">33</DIV>
      <DIV id=100560 style=
"DISPLAY: none"><INPUT   onblur="dis2('100560')" maxLength=30 size=11 value=33  id=100560_remark>
  </DIV>
   </span>
  
    <span onClick=
"dis('100561')">
  <DIV id=100561_ style=
"WORD-BREAK: break-all">33</DIV>
      <DIV id=100561 style=
"DISPLAY: none"><INPUT   onblur="dis2('100561')" maxLength=30 size=11 value=33  id=100561_remark>
  </DIV>
   </span>


</body>
</html>

原创粉丝点击