[
Lists Home |
Date Index |
Thread Index
]
Hi,
Need help on why i cant get result with this synthax. Highlighted in
red.
Appreciate any help!
<html>
<head>
<title>Partial Text Search</title>
<xml id='courselist' src="/XML Training/Demos/DOM Tree/courses.xml"></xml>
<script language="javascript">
var theXML, myNodeList, textToSearch;
var strNode = "";
var matches=0;
function showMatches() {
theXML = courselist.XMLDocument;
textToSearch = document.forms[0].searchtext.value;
myNodeList = theXML.selectNodes('course');
strNode += "<table border='1'><tr><th>Course
Title</th><th>Topics</th>";
strNode += "<th>Course
Length</th><th>Location</th><th>Description</th></tr>";
//alert(strNode);
alert(myNodeList.length);
for (var count=0; count<myNodeList.length; ++count) {
theItem = myNodeList(count);
alert(theItem.text);
if (theItem.text.match(textToSearch)) {
//Build a row with a pink background for matching
rows
strNode += "<tr bgcolor=#ffcccc>";
++matches;
} else {
//Build a row with a white background for
non-matching rows
strNode += "<tr>";
}
strNode += "<td>" + theItem.childNodes[0].text + "</td>"
strNode += "<td>" + theItem.childNodes[1].text + "</td>";
strNode += "<td>" + theItem.childNodes[2].text + "</td>";
strNode += "<td>" + theItem.childNodes[3].text + "</td>";
strNode += "<td>" + theItem.childNodes[4].text +
"</td></tr>";
}
strNode += "</table>";
strNode += "<h3>Number of matches: " + matches + "</h3>";
strNode += "Press your reload button to try another search.";
dataTarget.innerHTML = strNode;
}
</script>
</head>
<body>
<div align="center" id="dataTarget">
<form>
<h2>Course Information Search</h2>
Please enter a value to search for in our course list<br>
(partial queries OK): <input name="searchtext"><br><br>
<input type="Button"
value="Search the XML Document"
onClick="showMatches()">
</form>
</div>
</body>
</html>
Thanks & BR;
~erwin s.
|