ajax.dll动态创建表格与层

function GetTag()
{        
   if(tagIn != "")
{
   var txtIn = document.getElementById("search");      
   }
}

function tag_callback(response)
{
   ObjectBind(response);
   return;
}

function ObjectBind(response)
{
    var Str="";
    if(response.value!=null)
    {
        var ds = response.value;
        if(ds != null && typeof(ds) == "object" && ds.Tables != null)
        {
            if(ds.Tables[0].Rows.length > 0)
            {
                Str = "<div ls_t/" style=/"background-image:><table border=/"0/" width=/"100%/" cellpadding=/"0/" cellspacing=/"0/"><tr><td height=/"14/" f12/"style=/"padding-left:2px/"></td><td width=/"20/" align=/"center/"><a href=/"/"><img align=/"absmiddle/" src=/"" border=/"0/" width=/"12/" height=/"12/" img_close/" showwindowdivname.style.visibility='hidden'/"></a></td></tr></table></div><div ls_c/" style=/"border:1px solid #b2b2b2; margin:0px; cursor:hand;/">"

                for(var i=0; i<ds.Tables[0].Rows.length; i++)
                {
                    //document.all.textfield.value = ds[i];
                    var Pro_Name =ds.Tables[0].Rows[i].Pro_Name;    
                    var Pro_Id = ds.Tables[0].Rows[i].Pro_Id;
                    var Price_B = ds.Tables[0].Rows[i].Price_B+"元";
                    Str += "<table f12/" width=99% border=0 cellpadding=0 cellspacing=0 height=/"20/" ";
                    Str += "MouseMoveIn("+i+","+ds.Tables[0].Rows.length+")/" ";
                    Str += "MouseMoveOut("+i+")/" ";
                    Str += "SelectDivItem('"+Pro_Id+"')/"";
                    Str += "><tr>";
                   
                    //Str += "<td width=20% align=left f13/" td"+i+"_1/" style=/"padding-left:4px;font-size: 12px;; cursor:hand;/">";
                    //Str += Pro_Id;
                    //Str += "</td>";
                    Str += "<td width=50% align=left f14/" td"+i+"_2/" style=/"padding-left:2px;font-size: 12px;; cursor:hand;/">";
                    Str += "<a href=ProductDetail.aspx?Pro_Id="+Pro_Id+">"+Pro_Name+"</a>";
                    Str += "</td>";
                    Str += "<td width=30% align=left f14/" td"+i+"_3/" style=/"padding-left:2px;font-size: 12px;; cursor:hand;/">";
                    Str += Price_B;
                    Str += "</td>";
                    Str += "</tr></table></div>";
                    Str = Str.replace("undefined","");
                    //document.getElementById("showwindowdivname").innerHTML = Str;
                }//endfor
                Str += "</div>";
            }
        }//end ds!=null
      
    }//end response.value!=null

    if(GetObjValue("showwindowdivname"))
{
   if(Str=="")
   {
      document.getElementById("showwindowdivname").style.visibility="hidden";
   }
   else
   {
    document.getElementById("showwindowdivname").style.visibility="visible";
   }
      document.getElementById("showwindowdivname").innerHTML=Str;
}
}
function SelectDivItem(strWord)
{  
document.getElementById("textfield").value=strWord;
if(GetObjValue("showwindowdivname"))
{
   document.getElementById("showwindowdivname").style.visibility="hidden";
}
bSelectItemFlag=true;
document.getElementById("textfield").focus();
document.form1.submit();
return;

}

function GetObjValue(objName)
{
if(document.getElementById)
{
   return eval('document.getElementById("' + objName + '")');
}else
{
   return eval('document.all.' + objName);
   }
}

function CreateDiv()//创建div
{
var InputCom=document.getElementById("textfield");
InputCom.autocomplete="off";
var oResult = document.createElement('div');
oResult.id= 'showwindowdivname';
rightandleft=1;
topandbottom=1;
oResult.style.zIndex="2000";
oResult.style.paddingRight="0";
oResult.style.paddingLeft="0";
oResult.style.paddingTop="0";
oResult.style.paddingBottom="0";
oResult.style.visibility="hidden";
MoveDiv(oResult);
oResult.style.position="absolute";
oResult.style.backgroundColor="gray";
document.body.appendChild(oResult);
}

function MoveDiv(oResult)//移动div
{
if(oResult)
{
   InputCom=document.getElementById("textfield");
   oResult.style.left=MoveLeftDiv(InputCom)+"px";
   oResult.style.top=MoveTopDiv(InputCom)+InputCom.offsetHeight+"px";
   oResult.style.width=GetInputWidth(InputCom)+"px"
}
}

function MoveLeftDiv(InputCom)//计算left的距离
{
return MoveDivToPos(InputCom,"offsetLeft")
}

function MoveTopDiv(InputCom)//计算top的距离
{
return MoveDivToPos(InputCom,"offsetTop")
}

function MoveDivToPos(InputCom,nFlag)//根据text框移动
{
var pos=0;
while(InputCom)
{
   pos+=InputCom[nFlag];
   InputCom=InputCom.offsetParent;
}
return pos
}

function GetInputWidth(InputCom)//得到div的宽度
{
   return InputCom.offsetWidth
}

function OnDivSize()//移动div
{
if(GetObjValue('showwindowdivname'))
{
   MoveDiv(document.getElementById("showwindowdivname"));
}
}

function HideDiv()//关闭div
{
if(GetObjValue('showwindowdivname'))
{
   document.getElementById("showwindowdivname").style.visibility="hidden";
}
}

function InitDiv()//初始化div
{
if(bInitFlag==false)
{
    CreateDiv();
    bInitFlag=true;
}
}
function MouseMoveIn(iCurIndex,nMax)//当鼠标移到当前
{
for(i=0;i<nMax;i++)
{  
    if(iCurIndex!=i)
    {
     SetItemColor(i,'white','');
    }
    else
    {
     SetItemColor(i,'#4780DE','white');
    }
   }
bMouseInDivFlag =true;
upDownKeyNum=iCurIndex;
}
function SetItemColor(iCurIndex,nBKColor,nTextColor)//设置单元格的样式
{

document.getElementById("td"+iCurIndex+"_2").style.backgroundColor=nBKColor;
document.getElementById("td"+iCurIndex+"_2").style.color = nTextColor;

document.getElementById("td"+iCurIndex+"_3").style.backgroundColor=nBKColor;
document.getElementById("td"+iCurIndex+"_3").style.color = nTextColor;
}

function MouseMoveOut(iCurIndex)//当鼠标移出当前
{SetItemColor(iCurIndex,'white','');}

</script>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值