F.eks. kan du gøre sådan:
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"
"
http://www.w3.org/TR/html4/loose.dtd"><html>
<head>
<title>Procent op/ned</title>
<meta name="keywords" content="ameq/roenving;
http://www.eksperten.dk/spm/418192"><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
function procent_up() {
if (document.formen.procent.value >= 75 && document.formen.procent.value <= 100 ) {
document.formen.procent.value = '100';
}
if (document.formen.procent.value >= 50 && document.formen.procent.value < 75 ) {
document.formen.procent.value = '75';
}
if (document.formen.procent.value >= 25 && document.formen.procent.value < 50 ) {
document.formen.procent.value = '50';
}
if (document.formen.procent.value < 25) {
document.formen.procent.value = '25';
}
}
function procent_down() {
if (document.formen.procent.value >= 75 && document.formen.procent.value <= 100 ) {
document.formen.procent.value = '75';
}
if (document.formen.procent.value >= 50 && document.formen.procent.value < 75 ) {
document.formen.procent.value = '50';
}
if (document.formen.procent.value >= 25 && document.formen.procent.value < 50 ) {
document.formen.procent.value = '25';
}
if (document.formen.procent.value < 25) {
document.formen.procent.value = '0';
}
}
</script>
</head>
<body>
<br>
<form id="minForm" name="formen">
<input id="minInput" name="procent" type="text" value="Tom" onfocus="if(this.value==this.defaultValue)this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;" size="20">
<br>
<input type="checkbox" name="Op"> OP
<br>
<button name="button1" id="button1" onclick="if(this.form.Op.checked){procent_up()}else{procent_down()}">Mus over og tryk!</button><br><br>
</form>
</body>
</html>