How to use getElementsByClassName?
<p>Hey guys i getting error while using getElementByClassName.
My intension is that i want to change the color of multiple TEXT over the selection of an option from drop down list where each option is having different color.</p>

<p>Here i have assigned a single className to all text.</p>

<p>Here is my code.</p>

<pre><code>&lt;html&gt;
   &lt;head&gt;
      &lt;script type="text/javascript"&gt;
         function copyText(selectedElement) {
            var className = document.getElementsByClassName("incomeTypeSalary");
            for (i = 0; i &lt; className.length; i++)

            {
               className[i].style.color = selectedElement.options[selectedElement.selectedIndex].style.color;
            }

         }
      &lt;/script&gt;
   &lt;/head&gt;

   &lt;body&gt;
      &lt;div style="width:600px;border:1px solid black;float:left"&gt;
         &lt;select width="200px" id="selectedElement" onclick="copyText(selectedElement)"&gt;
            &lt;option style="color:red"&gt;Theta Saving Plan&lt;/option&gt;
            &lt;option style="color:green"&gt;Roth Plan&lt;/option&gt;
            &lt;option style="color:yellow"&gt;IRG Plan&lt;/option&gt;
            &lt;option style="color:PINK"&gt;II Plan&lt;/option&gt;
         &lt;/select&gt;
      &lt;/div&gt;
      &lt;div style="width:300px;border:1px solid black;float:left"&gt;
         &lt;span style="padding-top:30px;font-size:24px;font-family:arial:" class="incomeTypeSalary"&gt;Contribution&lt;/span&gt;
         &lt;table style="padding-top:24px"&gt;
            &lt;tr&gt;
               &lt;td&gt;
                  &lt;span class="incomeTypeSalary"&gt;Annual Salary&lt;/span&gt;
               &lt;/td&gt;
               &lt;td&gt;
                  &lt;input type="text" style="width:81px; direction:rtl;"&gt;
               &lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
               &lt;td&gt;
                  &lt;span class="incomeTypeSalary2"&gt;Annual Coomission&lt;/span&gt;
               &lt;/td&gt;
               &lt;td&gt;
                  &lt;input type="text" style="width:81px; direction:rtl;"&gt;
               &lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
               &lt;td&gt;
                  &lt;span class="incomeTypeSalary3"&gt;Annual Bonus&lt;/span&gt;
               &lt;/td&gt;
               &lt;td&gt;
                  &lt;input type="text" style="width:81px; direction:rtl;"&gt;
               &lt;/td&gt;
            &lt;/tr&gt;
         &lt;/table&gt;
      &lt;/div&gt;
   &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>PLs help me.Thanks in Advance.</p>
