Reputation: 45
I have combobox which id name is option and id name is "Chk" and my checkbox name is "chk"
and my script is look like this ;I put the script onclick but it is not work ;I check my script is loading ;I could not understand why it is not work ?Can you help me?
function checkAll()
{
//do some stuff you need here
document.getElementById('option').style="none";
}
<input type=\"checkbox\" name=\"Chk\" value=\"Chk\" onclick=\"checkAll()\">
Upvotes: 1
Views: 3585
Reputation: 795
you can do this with jquery easily.
//bind event to checkbox click
$(input[name=chk]).bind("click", function(e){
//select all checkboxes based on any criteria, here on base of class
$('.chkz').attr("checked", "checked");
$("#option").css("display", "none");
});
no need to put onclick="checkall()" with that. hop it helps,
Upvotes: 0
Reputation: 382686
You need to use display
property:
document.getElementById('option').style.display = "none";
This should work if you have assigned your element id="option"
If you want to check the checkbox (as function name suggests), you need to use checked
property instead:
document.getElementById('option').checked = true;
Upvotes: 2