Getting javascript error with a for loop even though it's working
<p>I'm trying to check a series of check boxes depending on the results I get from a string. Since the values in this string are separated by commas I do the following:</p>

<pre><code>var busLines = 'AB, CD, EF, GH, IJ, KL'
var temp = busLines.split(', ');
</code></pre>

<p>So now my array 'temp' should be the individual elements of my string:</p>

<pre><code>temp[0] = 'AB'
temp[1] = 'CD'
temp[2] = 'EF'
and etc...
</code></pre>

<p>Each one of those values that are being returned in my array of 'temp' correspond with a check box with the same ID. So when I loop through and value 'AB' comes up, the check box id='AB' will get checked.</p>

<p>That is why I try this:</p>

<pre><code>for (var i = 0; i &lt; temp.length; i++) {
    document.getElementById(temp[i]).checked = true;
}
</code></pre>

<p>When I test it out id does exactly what I want it to do, but it gives me the following error:</p>

<p>Message: 'document.getElementById(...)' is null or not an object
Line: 530
Char: 9</p>

<p>I don't understand why I am getting an error when what I want it to do works. Any suggestions?</p>
