I have a webpage form with a checkbox on it. I am trying to set the box to checked clicking an that exists on another part of the webpage using the onclick.
NONE of these seem to work (form and checkbox ID/NAME are all set properly):
<a href="#" onclick="document.getElementById('frmEditBasicBasic').active.checked=TRUE;"> test </a>
<a href="#" onclick="document.frmEditBasicBasic.active.checked=TRUE;"> test </a>
<a href="#" onclick="document.getElementById('active').checked=TRUE;"> test </a>
<a href="#" onclick="window.document.getElementById('frmEditBasicBasic').active.checked=TRUE;"> test </a>
<a href="#" onclick="window.document.frmEditBasicBasic.active.checked=TRUE;"> test </a>
<a href="#" onclick="window.document.getElementById('active').checked=TRUE;"> test </a>
You should use the
<label>element instead:Clicking this
<label>will automatically toggle the checkbox with IDactive. (If it’s a textbox, it will focus the textbox)To answer the question,
TRUEshould be lowercase. (Javascript is case-sensitive)