Hobatron
03-22-2012, 01:46 AM
The code so far works, but the rows form horizontally rather than vertically. This is my first time working with XMLHttpRequest() so it's probably pretty sloppy. Also, when the function runs again, it creates another row above the previous row, I'll add a screen shot.
http://tinyurl.com/7c7fylb - What it looks like when I've typed "bloodb" which means everything after the return if statement has ran twice
function findCard()
{
str = document.getElementById("cardName").value;
if (str.length<=4)
{
return;
}
xmlhttp=new XMLHttpRequest();
xmlhttp.open("GET","CardInfo/cards.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
var strLng = str.length;
var x = xmlDoc.getElementsByTagName("card");
var table = document.getElementById("cardDisplay")
var newRow = table.insertRow(0)
for (i=0; i {
var resaultStr = x[i].getElementsByTagName("name")[0].childNodes[0].nodeValue.slice(0,strLng)
if (str==resaultStr)
{
newRow.insertCell(0).innerHTML=x[i].getElementsByTagName("name")[0].childNodes[0].nodeValue
}
}
}
http://tinyurl.com/7c7fylb - What it looks like when I've typed "bloodb" which means everything after the return if statement has ran twice
function findCard()
{
str = document.getElementById("cardName").value;
if (str.length<=4)
{
return;
}
xmlhttp=new XMLHttpRequest();
xmlhttp.open("GET","CardInfo/cards.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
var strLng = str.length;
var x = xmlDoc.getElementsByTagName("card");
var table = document.getElementById("cardDisplay")
var newRow = table.insertRow(0)
for (i=0; i {
var resaultStr = x[i].getElementsByTagName("name")[0].childNodes[0].nodeValue.slice(0,strLng)
if (str==resaultStr)
{
newRow.insertCell(0).innerHTML=x[i].getElementsByTagName("name")[0].childNodes[0].nodeValue
}
}
}