0

I have been banging my head over this (probably simple) issue and am missing something really basic. Why does this first code display the expected output

xmlhttp=xmlhttp.responseXML;

document.getElementById("CenterDataBox").innerHTML= xmlhttp.getElementsByTagName("ShowDay")[0].childNodes[0].nodeValue;

and this second one doesn't? I think this is something really simple I've overlooking.

xmlhttp=xmlhttp.responseXML;

var DayOfShow = xmlhttp.getElementsByTagName("ShowDay")[0].childNodes[0].nodeValue;
document.getElementById("CenterDataBox").innerHTML= DayofShow;
1
  • Use the browser's console! It will tell you the error. Commented Mar 4, 2015 at 1:26

3 Answers 3

1

The error is that your variable DayOfShow is not what you're using. You're using DayofShow, without capital '0' letter.

Sign up to request clarification or add additional context in comments.

1 Comment

OK, now that's just embarrassing. Hahahaha Thank you for the quick edit, that fixed it. My eyes must be getting tired.
1

JavaScript is case-sensitive.

= DayofShow should be = DayOfShow in example 2.

1 Comment

Thanks, as I noted above, I think I'm just tired, and looked at it too long. Thank you for your time and effort
0

You got mispelling of set variable. In example 2 i assume you're getting error var not defined. That is because you set value to DayOfShow and below you set inner html to DayofShow. Javascript is case sensitive.

Here you can read more about JS.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.