Saturday, August 2, 2008

Javascript for Work WIth Ajax

// JavaScript Document
//var xmlHttp = //createXmlHttpRequestObject();

//IF Page Submit/Postback
TimerId=0;
TimerId=setTimeout('GetPastDtl(document.getElementById("CompList").value)',1000);
function createXmlHttpRequestObject()
{
try
{
// try to create XMLHttpRequest object
//xmlHttp = new //XMLHttpRequest();
}
catch(e)
{
var //XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.5.0", "MSXML2.XMLHTTP.4.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP");
//for (var i=0; i";
document.getElementById('DeptList').options.add(k);
for (var i=0; i
document.getElementById('EmpList').options.add(l);
for (var m=0; m0)
{
i=document.getElementById('EditedRowNo').value;
GetEditMode('divEd'+i,'divRd'+i,'divNameEd'+i,'divNameRd'+i,'divMailEd'+i,'divMailRd'+i,ENameDtlArray.length);
}

}
function GetEmpDetail()
{
CompId=document.getElementById('CompList').value;
DeptId=document.getElementById('DeptList').value;
EmpId=document.getElementById('EmpList').value;
PageSize=document.getElementById('hdnPageSize').value;
Offset=document.getElementById('hdnoffset').value;
CurrnentPg=document.getElementById('hdnCurrPg').value;
TotalPg=document.getElementById('hdnTotalRow').value;
if (xmlHttp)
{
try
{
if((xmlHttp.readyState==0)||(xmlHttp.readyState==4))
{
var params = "CompId=" + CompId+"&DeptId="+DeptId+"&EmpId="+EmpId+"&PageSize="+PageSize+"&Offset="+Offset;
//xmlHttp.open("GET", "Xml/EmpToDetail.php?" + params, true);
//xmlHttp.onreadystatechange = EmpDtlRequestStateChange;
//xmlHttp.send(null);
}
else
{
setTimeout('GetEmpDetail()',1000);
}
}
catch (e)
{
alert("Can't connect to server:\n" + e.toString());
}
}
}
function CreateTd(id,style,className,innerHTML)
{
Td=document.createElement("td","");
Td.setAttribute("id",id);
Td.setAttribute("style",style);
Td.className=className;
Td.innerHTML=innerHTML;
return Td;
}
function CreateTextBox(AttributeArray,ValueArray,Value)
{
inputName=document.createElement("input","");
for(i=0;i<=AttributeArray.length-1;i++) { inputName.setAttribute(AttributeArray[i],ValueArray[i]); } inputName.value=Value; return inputName; } function GridTable() { document.getElementById("EmpDetail").innerHTML=""; div=document.getElementById("EmpDetail"); //Generate Table Table=document.createElement("table",""); Table.setAttribute("style","width:100%"); Table.setAttribute("cellpadding","0"); Table.setAttribute("cellspacing","0"); Table.setAttribute("border","1"); //Generate Row Tr=document.createElement("tr",""); //Generate Column1 Td1=CreateTd('','width:40%','TdDataHeading','Name'); Tr.appendChild(Td1); //Generate Column2 Td2=CreateTd('','width:40%','TdDataHeading','Email'); Tr.appendChild(Td2); //Generate Coloumn3 Td3=CreateTd('','width:20%','TdDataHeading','Manage'); Tr.appendChild(Td3); Table.appendChild(Tr); ENameDtlArray = xmlRoot.getElementsByTagName("Ename"); EmailDtlArray = xmlRoot.getElementsByTagName("Email"); EContactIdArray=xmlRoot.getElementsByTagName("EContactId"); for (var i=0; i