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
https://forums.phpfreaks.com/topic/86039-disabling-checkboxes/
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
https://forums.phpfreaks.com/topic/86039-disabling-checkboxes/#findComment-439443
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.