Try this ...
Code:
<html>
<head>
<title>Button Changes</title>
<script type="text/javascript">
http://www.webdeveloper.com/forum/showthread.php?t=225370
function Add() {
var N = parseFloat(document.getElementById('Accum').value);
if (isNaN(N)) { alert('Math requires numbers'); return; }
document.getElementById('Accum').value = N + 1;
}
function Sub() {
var N = parseFloat(document.getElementById('Accum').value);
if (isNaN(N)) { alert('Math requires numbers'); return; }
document.getElementById('Accum').value = N - 1;
}
function Mult() {
var N = parseFloat(document.getElementById('Accum').value);
if (isNaN(N)) { alert('Math requires numbers'); return; }
document.getElementById('Accum').value = N * 5;
}
function Div() {
var N = parseFloat(document.getElementById('Accum').value);
if (isNaN(N)) { alert('Math requires numbers'); return; }
document.getElementById('Accum').value = N / 5;
}
</script>
</head>
<body>
<form id="myForm" action="" onsubmit="return false">
Initial value: <input type="text" value="1" id="Accum"><br>
<button type="text" value="1" onClick="Add('Accum')">Add 1</button>
<button type="text" value="1" onClick="Sub('Accum')">Sub 1</button>
<button type="text" value="1" onClick="Mult('Accum')">Multiply 5</button>
<button type="text" value="1" onClick="Div('Accum')">Divide 5</button>
</form>
</body>
</html>
Bookmarks