Okay this is what I am having trouble with Button "d" i want it to run in a sequence of button A, b, then c. then b, c, then a. and soforth. I've been working at it for a week now. I have button a b and c working just fine
//begin code here...
//check to see if there is a value in the input field, & to see if that value is numeric only.
//When button A is clicked it should add 1 to the numeric value in input field
//z=x+1 (z++)
function increment(txtBox) {
document.getElementById('txtBox').value = parseFloat(document.getElementById('txtBox').value) + 1;
document.aform1.txtBox.focus();
}
//When button B is clicked it should divide by 2 to the numeric value in the input field
function divideThem(txtBox){
txtBox.value = parseFloat(txtBox.value) / 2;
}
//When button C is clicked it should subtract by 1 to the numeric value in the input field
//z=x-1 (z--)
function decrement(txtBox) {
document.getElementById('txtBox').value = parseFloat(document.getElementById('txtBox').value) - 1;
document.aform1.txtBox.focus();
}
//When button D is clicked it should go through the sequence of A, B then C.
/*function runSequence(txtBox) {
document.aform1.txtBox.value
PreviousDisplayValue = document.aform1.txtBox.value
if(txtBox =="+ 1") {
document.aform1.txtBox.value = parseFloat(PreviousDisplayValue + CurentDisplayValue)
}
else if(txtBox == "/ 2") {
document.aform1.txtBox.value = parsFloat(PreviousDisplayValue / CurentDisplayValue)
}
else if(txtBox == "- 1") {
document.aform1.txtBox.value = parFloat(PreviousDisplayValue - CurentDisplayValue)
}
document.aform1.txtBox.focus();
}*/
/*function runSequence (txtBox) {
if document.getElementById('txtBox').vaule = + 1
}else{txtBox.value = parseFloat(txtBox.value) / 2;
}*/
and here is the HTML
<body>
<form name="aform1" id="aform1">
<input type="text" name="txtBox" id="txtBox" value="0" size="4" maxlength="4"/>
<input type="button" value="A" onClick="increment(txtBox);" />
<input type="button" value="B" onClick="divideThem(txtBox);" />
<input type="button" value="C" onclick="decrement(txtBox);" />
<input type="button" value="D" onclick="runSequence(txtBox);" />
</form>
</body>
I got really frustrated and couldn't finish the coding on the sequence...