Below HTML Script implemets tristate checkbox for handling 3 values using the checkbox. Each click will change the state of the value and assign the new value
In the example below tick will have value 1 , cross value 0 and unchecked will have value -1
<HTML>
<HEAD>
<TITLE> Check Box Test</TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script>
function showf(){
if(document.getElementById("i1").style.display=='' && document.getElementById("i2").style.display=='none'){
document.getElementById("i3").style.display = '';
document.getElementById("i1").style.display = 'none';
document.t1.value = -1;
}else if(document.getElementById("i3").style.display=='' && document.getElementById("i1").style.display=='none'){
document.getElementById("i2").style.display = '';
document.getElementById("i3").style.display = 'none';
document.t1.value = 0;
}else if(document.getElementById("i2").style.display=='' && document.getElementById("i3").style.display=='none'){
document.getElementById("i1").style.display = '';
document.getElementById("i2").style.display = 'none';
document.t1.value = 1;
}
}
</script>
</HEAD>
<BODY>
<form id="t" name="tform" action="testsubmit.php" method="post">
<input type="hidden" name="t1" value="1"><img src="tick.gif" id="i1" border="1" onclick="showf();">
<input type="hidden" name="t1"><img src="none.gif" id= "i2" border="1" onclick="showf();" style="display:none;">
<input type="hidden" name="t1"><img src="cross.gif" id= "i3" border="1" onclick="showf();" style="display:none;">
</form>
</BODY>
</HTML>
No comments:
Post a Comment