1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| <?php
$variable="0";
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="sheet.css">
<script>
var buttonstate=1;
function onoff(element)
{
buttonstate= 1 - buttonstate;
var blabel, bstyle, bcolor;
window.alert(buttonstate);
if(buttonstate)
{
blabel="on";
bstyle="green";
bcolor="lightgreen";
}
else
{
blabel="off";
bstyle="lightgray";
bcolor="gray";
}
var child=element.firstChild;
child.style.background=bstyle;
child.style.color=bcolor;
child.innerHTML=blabel;
}
</script>
</head
<body>
<button class="onoff" onclick="onoff(this)"><div>off</div></button>
<input type="checkbox" name="checkbox" value="checkbox" <?php if ($variable == 1) { echo "checked"; }?> >
</body>
</html> |