Jump to content

Disabling checkboxes.


DJTim666

Recommended Posts

I am trying to disable some checkboxes on my website depending on how many current checkboxes are clicked. So for example I am going to have 6 checkboxes and if 2 are clicked then I want the other 4 to be disabled. I tried using an array, I tried plusing and minusing and I tried some other ways, all failing.

 

If someone could PLEASE help me that would be greatly appreciated.

 

--

DJ

Link to comment
Share on other sites

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<script>
function go(){
var objs=document.getElementsByTagName("input");
var num=0;
for(k=0;k<objs.length;k++){
	if(objs[k].type=="checkbox" && objs[k].checked==false){
		num+=1;
		objs[k].disabled="false";
	}
}
}
</script>
<BODY>
  <input type="checkbox"><input type="checkbox"><input type="checkbox"><input type="checkbox"><input type="checkbox"><input type="checkbox">

  <input type="button" value="go go go" onclick=go() >
</BODY>
</HTML>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.