Iamthestig
Programmer
I have been asked to change our intranet to change the background color of cells when a radiobutton is clicked. There are 160 radio buttons and I'm looking of a way to do this with minimal code changes. Here is an example:
So I can give my td an ID ("MyCell") and use the onclick of the radiobutton to change the cell but I don't want to do this 160 times. Is there a way to use onclick and get the parent td of the radiobutton?
I will also need to reset the backcolor when a different radiobutton is clicked.
Thanks for any help.
HTML:
<!-- Question 1 -->
<tr valign="top">
<td class="style20">
<asp:Textbox runat="server" ID="txtqDesc1" Width="120px" CssClass="TableContent" Text=" " Wrap="true" TextMode="MultiLine" ReadOnly="true" Height="50px"/>
<asp:Textbox runat="server" ID="txtQNo1" Visible="false" Text="" />
</td>
<td class="TableContent" runat="server" id="MyCell" align="left" height="80">
<asp:Label runat="server" ID="txtAnswer1_0" Visible="true" Text="Question 1"/>
<asp:RadioButton runat="server" ID="radAnswer1_0" GroupName="Q1" onclick="javascript:MyCell.style.background=gray';" />
</td>
<td class="TableContent" align="left" height="80">
<asp:Label runat="server" ID="txtAnswer1_1" Visible="true" Text="Question 2"/>
<asp:RadioButton runat="server" ID="radAnswer1_1" GroupName="Q1"/>
</td>
<td class="TableContent" align="left" height="80">
<asp:Label runat="server" ID="txtAnswer1_2" Visible="true" Text="Question 3/>
<asp:RadioButton runat="server" ID="radAnswer1_2" GroupName="Q1"/>
</td>
So I can give my td an ID ("MyCell") and use the onclick of the radiobutton to change the cell but I don't want to do this 160 times. Is there a way to use onclick and get the parent td of the radiobutton?
I will also need to reset the backcolor when a different radiobutton is clicked.
Thanks for any help.