using a string with object name to refrence object

Giganews Newsgroups
Subject: using a string with object name to refrence object
Posted by:  Charles Russell (cer…@surewest.net)
Date: Mon, 21 Jul 2003

I am new to JavaScript and I am  currently having a problem that I can find
no clear solution to.  I have a series of button contained in a row. These
rows are defined as follows:
<tr> <!--This is Mondays row -->
    <td><button type="button" value="Monday" id="Monday" style="BACKGROUND:
yellow" onclick='ScheduleDay("Monday")'>Monday</button></td>
    <td><button type="button" value="M830" id="M830" style="BACKGROUND:
white">8:30</button></td>
    <td><button type="button" value="M900" id="M900" style="BACKGROUND:
white">9:00</button></td>
    <td><button type="button" value="M930" id="M930" style="BACKGROUND:
white">9:30</button></td>
    <td><button type="button" value="M1000" id="M1000" style="BACKGROUND:
white">10:00</button></td>
    <td><button type="button" value="M1030" id="M1030" style="BACKGROUND:
white">10:30</button></td>
    <td><button type="button" value="M1100" id="M1100" style="BACKGROUND:
white">11:00</button></td>
    <td><button type="button" value="M1130" id="M1130" style="BACKGROUND:
white">11:30</button></td>
    <td><button type="button" value="M1200" id="M1200" style="BACKGROUND:
white">12:00</button></td>
    <td><button type="button" value="M1230" id="M1230" style="BACKGROUND:
white">12:30</button></td>
    <td><button type="button" value="M100" id="M100" style="BACKGROUND:
white">1:00</button></td>
    <td><button type="button" value="M130" id="M130" style="BACKGROUND:
white">1:30</button></td>
    <td><button type="button" value="M200" id="M200" style="BACKGROUND:
white">2:00</button></td>
    <td><button type="button" value="M230" id="M230" style="BACKGROUND:
white">2:30</button></td>
    <td><button type="button" value="M300" id="M300" style="BACKGROUND:
white">3:00</button></td>
    <td><button type="button" value="M330" id="M330" style="BACKGROUND:
white">3:30</button></td>
    <td><button type="button" value="M400" id="M400" style="BACKGROUND:
white">4:00</button></td>
    <td><button type="button" value="M430" id="M430" style="BACKGROUND: whi
te">4:30</button></td>
</tr>

The ScheduleDay function displays the gets the value of a series of radio
buttons.  The problem is that the value is a string corresponding to the  ID
attribute of the button ( I have tried the name attribute to).  I want to
use this string to change the background color of the button using a
function prototyped likeColorPeriodBtn(Btnname,Color).  I am getting very
frustrated any help  would be appreciated.

Replies