...

View Full Version : getElementById



priyapratheep
05-15-2008, 07:19 AM
In my form i have employee Id and grade.

When i type the employee id , if the id is already in database then it will be displayed near to employee id text box

When i select grade then all the grade above i selected should be displayed in next row of the table next to reporting to row...


for employee id

out.println("<TD><input type=\"Text\" name=\"empID\" value=\""+""+"\" onkeyup=\"showID(this.value)\"><span id=\"empid1\"></span></TD>");

<script src="newemp.js"></script>


Code:

var xmlHttp

function showID(str)
{
if (str.length==0)
{
document.getElementById("empid1").innerHTML="";
return;
}
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
{
alert ("Your browser does not support AJAX!");
return;
}
var url="getID.jsp";
url=url+"?q="+str;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateChanged()
{
if (xmlHttp.readyState==4)
{
document.getElementById("empid1").innerHTML=xmlHttp.responseText;
}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}For the grade drop down box
out.println("<div id=\"txtGrading\"></div>"); here i want to disply the drop down box

<div id="txtGrading"></div>

out.println("<Select name=\"staff_grade\" onchange=\"showHintGrade(this.value)\" >");calling side

<script type="text/javascript" src="grading.js"></script>

grading.js


Code:

var xmlHttp
var s = new Array(50);
function showHintGrade(str)
{
if (str.length==0)
{
document.getElementById("txtGrading").innerHTML="";
return;
}
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
{
alert ("Your browser does not support AJAX!");
return;
}
var url="GetHint1.jsp";
url=url+"?q="+str;
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateChanged()
{
if (xmlHttp.readyState==4)
{
document.getElementById("txtGrading").innerHTML=xmlHttp.responseText;
}
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;}I don't have much idea

please help



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum