How to uncheck a check box on another check click and also set the control visibility to false
I write the sample code to un-check a check box on another check box click. At the same time i would like to set the visibilty of control to false based on check or uncheck of check box here is what i have written
<form name="formName">
<input type="checkbox" name="priorityHigh"
onclick="if(this.checked) {document.formName.priorityLow.checked=false;}">High Priority
<input type="checkbox" name="priorityLow"
onclick="if(this.checked) {document.formName.priorityHigh.checked=false;}">Low Priority
<asp:TextBox ID="txtLastName" runat="server" visible=
"false">
</asp:TextBox>
<asp:TextBox ID="txtfirstName" runat="server" visible=
"false">
</asp:TextBox>
</form>
Now assume on first check box click i will have visibility of text box1 now on second check box click i would like to uncheck the first one and set the visibility of textbox1 to false and make the second one visib开发者_如何学JAVAle to true.
Any help please
use
document.getElementById("txtLastName").style.visibility="hidden/visible"
to set the visibility and
document.getElementById("checkboxId").checked=true
to set checkbox value or the same you did.
I don't know how to do it in JS, but I got some jQuery pointers.
First you capture the click event in jquery. Then you select all checkboxes http://api.jquery.com/checkbox-selector/ and uncheck them. then you check the on clicked using the "this" keyword. To se an input visible our invisible you can use the hide/show functions http://api.jquery.com/hide/
精彩评论