PDA

View Full Version : disable check box to be checked when function is invoked


frontline
03-05-2003, 09:08 AM
Hello
i have checkbox that invoke function onclick method something like :
<input type="checkbox" name="blah" onclick="foo(this.name);" >
now i like that the function foo() will disable me the option to check the check box , what is the way to perform this task?
thanks

glenngv
03-05-2003, 10:02 AM
<input type="checkbox" name="blah" onclick="foo(this);" >

function foo(objChk){
alert(objChk.name);
objChk.disabled=true;
}

frontline
03-05-2003, 10:14 AM
hi tnx for the reply ,BUT this is not what im looking for
in your case the user checks that input checkbox , i like that the user will not be ABLE to do that
not disable the checkbox ,but not let the checkbox to be checked
hope i made my seld clear here..
tnx

arnyinc
03-05-2003, 01:44 PM
Is this what you need?

<html>
<head>
<script>
var allow_check=true;

function foo(){
allow_check=false;
}
</script>
</head>
<body>
<input type="checkbox" name="blah" onclick="return allow_check;" >
<input type="button" onclick="foo();" value="disable">
</body>
</html>

glenngv
03-10-2003, 12:24 AM
or simply:

<input type="checkbox" name="blah" onclick="return false">

but why not just disable it:

<input type="checkbox" name="blah" disabled>