Is it possible to use variables as dom elements?
<p>I have a several input fields in a form each having a unique name. For example, to change the color I would do:</p>

<pre><code>testForm.username.style.background = "yellow";
</code></pre>

<p><code>username</code> being the name of the input and <code>testform</code> being the form name</p>

<p>I want to do this: replace <code>username</code> with a variable <code>elem</code> so that when I call the function to change the background color I don't need to have a separate function for every unique field. I would just send the <code>elem</code> name and that function would work for every field. </p>

<pre><code>testForm.elem.style.background = "yellow";
</code></pre>

<p>My problem is it doesn't work. For example it passed the <code>elem</code> into the function fine, but it says that <code>testForm.elem.style</code> is <code>null</code>. For some reason javascript doesn't like variables for element names I'm guessing?</p>
