Se usi JQuery ti viene abbastanza facile. Puoi usare degli id (o degli attributi in generale) e sfruttare i selettori:
codice:
<html>
<head>
<script src="http://code.jquery.com/jquery-1.4.3.min.js"></script>
<script>
$(document).ready(function()
{
$("#cb1").click(function()
{
var cb1 = $(this);
var disabled = null;
if (cb1.is(":checked"))
{
disabled = "disabled";
}
else
{
disabled = "";
}
$.each($("input[id^=\"cb\"]"), function()
{
if($(this).attr("id") != cb1.attr("id"))
{
$(this).attr("disabled", disabled);
}
});
});
$("input[id^=\"cb\"]").change(function()
{
var anyChecked = false;
if($(this).attr("id") != "cb1")
{
if($(this).is(":checked"))
{
$("#cb1").attr("disabled", "disabled");
return;
}
$.each($("input[id^=\"cb\"]"), function()
{
if($(this).attr("id") != "cb1" && $(this).is(":checked"))
{
anyChecked = true;
return;
}
});
if(!anyChecked)
{
$("#cb1").attr("disabled", "");
}
else
{
$("#cb1").attr("disabled", "disabled");
}
}
});
});
</script>
</head>
<body>
<input type="checkbox" id="cb1"/>1
<input type="checkbox" id="cb2"/>2
<input type="checkbox" id="cb3"/>3
<input type="checkbox" id="cb4"/>4
<input type="checkbox" id="cb5"/>5
</body>
</html>
Se non usi JQuery, devi crearti tu lo strato di selezione, il resto rimane simile.