I have a checkbox and a label for the checkbox that is actually coded as another field:
<td style="text-align:left; width:210px; font-size:11px;
height:20px;vertical-align:middle; " colspan="2" >
<asp:CheckBox ID="Strengthx" runat="server" AutoPostBack="false"/>
<a style="color: black;text-decoration: none;" id="Strength"
href="javascript:void(0)"
onclick="addlinethrough(Strength)"
ondblclick="removelinethrough(Strength)">Strength</a>
</td>
There are choices available to the user: check the checkbox / uncheck the checkbox; click the label / unclick the label
By clicking the label, the textDecoration changes to line-through. If you double click the label, the textDecoration will change back to normal.
I also intend for clicking the label to apply line-through and also "uncheck" the checkbox. To enable this with one set of javascripts, I've named the labels and checkboxes similarly. label id = "Strength" checkbox id = "Strengthx" The checkbox always has an appended "x".
The following is my current javascript code which doesn't seem to be working correctly. The checkbox remains checked even after clicking the label.
function addlinethrough(elem) {
elem.style.textDecoration = "line-through";
document.getElementById(elem+x).checked = false;
return false;
}
function removelinethrough(elem) {
elem.style.textDecoration = "none";
return false;
}
It seems like there may be an issue with recognizing the checkbox id in the script.