<body>
<h3> Three-state checkbox (change order: unchecked->grey selected->white selected)</h3><br>
<form name=test>
Checkbox based on onclick:<br>
<input type=checkbox name=checkbox0 flag=0 onclick='gray(this)'>Initialize to unselected checkbox<br>
</td><td><input type=checkbox name=checkbox1 flag=1 onclick='gray(this)'>Initialize to the white selected checkbox<br>
</td><td><input type=checkbox name=checkbox2 flag=2 onclick='gray(this)'>Initialize to gray-selected checkbox<br>
Checkbox changes according to onpropertychange:<br>
<input type=checkbox name=checkbox3 onpropertychange='gray2(this)'>Initialize to unchecked checkbox
</form>
<script language=javascript>
//For onclick, a custom attribute flag is required.
function gray(c)
{
switch()
{
//When flag is 0, it is an unselected state
case '0':=true;=true;='2';break;
//When flag is not 1, it is selected in white
case '2':=true;=false;='1';break;
//When flag is 2, it is gray selected
case '1':=false;=false;='0';break;
}
}
// Used for onpropertychange
function gray2(c)
{
=;
}
//Onload used for body, judge the status of checkbox based on the flag attribute of checkbox
function check()
{
for(var i = 0;i<;i++)
{
var ele = [i];
if(!=null)
{
if(=='0')
{
= false;
= false;
}
if(=='1')
{
= true;
= false;
}
if(=='2')
{
= true;
= true;
}
}
}
}
=check;
</script>