要求点击输入框,弹出浮动div,div覆盖在输入框上方,可进行修改操作。
效果图:
[img]http://dl.iteye.com/upload/attachment/199344/5a234ced-0580-39e1-b054-92ed98c9dfad.jpg[/img]
效果图:
[img]http://dl.iteye.com/upload/attachment/199344/5a234ced-0580-39e1-b054-92ed98c9dfad.jpg[/img]
function editBehaviorDiv(obj,id,value){
var div=document.getElementById("editBehaviorDiv");
if(div!=null)
document.body.removeChild(div);
saveRiskInfo();
div = document.createElement("div");
div.id="editBehaviorDiv";
div.style.position='absolute';
var op=getoffset(obj);
div.style.top=op[0];
div.style.left=op[1];
div.style.zIndex =100;
div.style.backgroundColor='#ecf1f6';
div.style.border="1px solid #666";
//div.className="td1";
div.innerHTML="<textarea name='behaviorValue' cols='50' rows='8'>"+value+
"</textarea><br/><input type='button' value='修改' onclick=\"saveBehaviorname(this.parentNode,'"+id+"')\" />"+
"<input type='button' value='取消' onclick='document.body.removeChild(this.parentNode);'/>";
document.body.appendChild(div);
document.all.behaviorValue.focus();
}
function saveBehaviorname(obj,id){
var riskbehavior=document.all.behaviorValue.value;
LawriskUtil.saveBehaviorName(id,riskbehavior,function(data){
//obj1.value=riskbehavior;
getNewRiskList();
document.body.removeChild(obj);
});
}
function getoffset(e)
{
var t=e.offsetTop;
var l=e.offsetLeft;
while(e=e.offsetParent)
{
t+=e.offsetTop;
l+=e.offsetLeft;
}
var rec = new Array(1);
rec[0] = t;
rec[1] = l;
return rec
}
测试
<input type='text' size='20' name='riskbehavior'value='行为'
onclick=editBehaviorDiv(this,'1','行为') >