View Single Post
Old 12-17-2010, 06:24 PM   PM User | #2
pigpen
Regular Coder

 
Join Date: Dec 2007
Posts: 137
Thanks: 1
Thanked 21 Times in 21 Posts
pigpen is on a distinguished road
I see some errors.

id naming error:

First, you have "Name" with capital "N" in your th tag:
Code:
<th id="Name" colspan="2">
But in your JavaScript code, you are trying to find 'name' in lowercase.

Code:
document.getElementById('name').innerHTML = txt;
This will cause an error (can't set null value to innerHTML), because there is no id with "name".

Fix your th tag and make the id lowercase:
Code:
<th id="name" colspan="2">
XML errors:

You aren't properly accessing your 'name' node, as you need an index value(like [0]), and also you aren't accessing the value in the child of that node by using nodeValue.

Replace these lines:
Code:
txt="";
x=xmlhttp.responseXML.documentElement.getElementsByTagName('name');
txt=x.data;
document.getElementById('name').innerHTML=txt;;
With this:
Code:
var txt = "";
var x = xmlhttp.responseXML.documentElement.getElementsByTagName('name')[0];
var y = x.childNodes[0];
txt = y.nodeValue;

document.getElementById('name').innerHTML = txt;
pigpen is offline   Reply With Quote
Users who have thanked pigpen for this post:
Dornith (12-18-2010)