Attempting to make an FAQ in which the questions are in a list. They link to a javascript function which writes the answer to a DIV just below the appropriate question, using innerHTML.

The problem is, I'm new at Javascript and my browser (IE6, haven't tested in others yet) is telling me that "document.getElementById(...) is null or not an object".

Here's the code:

var answer=new Array();
answer[0]="Answer to 1st question.";
answer[1]="Another answer";
...and many more

var isAll = 0;
var isID = 0;
var isLayers=0;
if(document.getElementById) {isID=1;}
else {
if (document.all) {isAll = 1;}
else {
browserVersion = parseInt(navigator.appVersion);
if ((navigator.appname.indexOf('Netscape') != -1) && browserVersion == 4)) {isLayers = 1;}
}}

function show(ansnum){
var space = eval("space" + ansnum);
if (isID) {document.getElementById(space).innerHTML=' '; document.getElementById(space).innerHTML = answer[ansnum]; }
else {
if (isAll) {document.all[space].innerHTML=answer[ansnum]; }
else {
if (isLayers) {document.layers[space].document.open(); document.layers[space].document.write(answer[ansnum]); document.layers[space].document.close();}
}}
}



And in the document body:

<ul>
<li><a href="javascript:show(0)">Where is the answer to this question?</a><br>
<div id="space0"> </div>
<li><a href="javascript:show(1)">Why am I getting an error?</a><br>
<div id="space1"> </div>

The catch is when I hard code document.getElementById('space0').innerHTML it works fine. So is it something to do with the eval to make the div name? Like I said very new at JS.

Thanks