i have attached my coding in this. here is an error. that is array is undefined. any one can solve this pbm?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"
http://www.w3.org/tr/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<style>
html {background-color:#eeeeee}
body {
background-color:#ffffcc;
font-family:Tahoma,Arial,Helvetica,sans-serif;
font-size:12px;
margin-left:15%;
margin-right:15%;
border:3px groove #006600;
padding:15px
}
h1 {
text-align:left;
font-size:1.5em;
font-weight:bold
}
</style>
<script type="text/javascript">
// global flag
var isIE = false;
// global request and XML document objects
var req;
//document.getElementById("hiddenDIV").style.visibility="visible";
//document.getElementById("hiddenDIV").innerHTML=xhr.rs(0);
function loadXMLDoc(url) {
// branch for native XMLHttpRequest object
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
req.onreadystatechange = processReqChange;
req.open("GET", url, true);
req.send(null);
// branch for IE/Windows ActiveX version
} else if (window.ActiveXObject) {
isIE = true;
req = new ActiveXObject("Microsoft.XMLHTTP");
if (req) {
req.onreadystatechange = processReqChange;
req.open("GET", url, true);
req.send();
}
}
}
function loadDoc(evt) {
// equalize W3C/IE event models to get event object
evt = (evt) ? evt : ((window.event) ? window.event : null);
if (evt) {
// equalize W3C/IE models to get event target reference
var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
if (elem) {
try {
if (elem.selectedIndex > 0) {
loadXMLDoc(elem.options[elem.selectedIndex].value);
}
}
catch(e) {
var msg = (typeof e == "string") ? e : ((e.message) ? e.message : "Unknown Error");
alert("Unable to get XML data:\n" + msg);
return;
}
}
}
}
// retrieve text of an XML document element, including
// elements using namespaces
function getElementTextNS(prefix, local, parentElem, index) {
var result = "";
if (prefix && isIE) {
// IE/Windows way of handling namespaces
result = parentElem.getElementsByTagName(prefix + ":" + local)[index];
} else {
// the namespace versions of this method
// (getElementsByTagNameNS()) operate
// differently in Safari and Mozilla, but both
// return value with just local name, provided
// there aren't conflicts with non-namespace element
// names
result = parentElem.getElementsByTagName(local)[index];
}
if (result) {
// get text, accounting for possible
// whitespace (carriage return) text nodes
if (result.childNodes.length > 1) {
return result.childNodes[1].nodeValue;
} else {
return result.firstChild.nodeValue;
}
} else {
return "n/a";
}
}
// display details retrieved from XML document
function showDetail(evt) {
evt = (evt) ? evt : ((window.event) ? window.event : null);
var item, content, div;
if (evt) {
var select = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
if (select && select.options.length > 1) {
// copy <content:encoded> element text for
// the selected item
item = req.responseXML.getElementsByTagName("item")[select.value];
content = getElementTextNS("content", "encoded", item, 0);
div = document.getElementById("details");
div.innerHTML = "";
// blast new HTML content into "details" <div>
div.innerHTML = content;
}
}
}
//for retrieving data
function ConDB()
{
var s1 = document.fm.t1.value;
var nm = s1.substring(0,2);
var n1 = null;
if (nm.length >= 2)
{
var conn = new ActiveXObject("ADODB.Connection") ;
var connectionstring="Provider=SQLOLEDB;Password=sa;User ID=sa;Initial Catalog=TEST;Data Source=192.168.1.83;"
conn.Open(connectionstring);
var rs = new ActiveXObject("ADODB.Recordset");
var recordarray=new array();
var i=0;
rs.Open("SELECT * FROM STUD WHERE NAME LIKE '%" + nm + "%'", conn);
if (!rs.eof && !rs.bof)
{
rs.moveFirst
while(!rs.eof)
{
// var oOption = document.createElement("OPTION");
// oSelect.options.add(oOption);
// oOption.innerText = rs(0);
recordarray[i]=rs(0);
i+=1;
rs.moveNext
}
}
else
{
document.write('No matches found!');
}
rs.close;
conn.close;
}
else
{
document.write(" plz enter more than one char");
}
}
</script>
</head>
<body>
<h1><b><center>Search Engine</center></b></h1>
<hr />
<form name="fm">
<p><center>Enter the string to search</center><br />
<center><input type="text" name="t1" value="" onkeyup="ConDB();"></center>
</p>
<p>Items:<br />
<select size="10" id="topics" onchange="showDetail(event)">
<option value="">output of search details</option>
</select>
</p>
</form>
<div size="10" id="details"><span></span></div>
</body>
</html>