OK cool thanks for the tips. I figured out all the javascript I needed now I need help with the HTML. My numbers are not showing up when i click on the button. It has to do with appenddigit right? Here is the finished Javascript:
Code:
// cal Applet- John Falco- 20 October 2010
var HasDecimal;
function ClearTB() {
document.forms.kpd.display.value="0";
HasDecimal = false;
}
// ------------------------------------------------------------------------------------------
// function AppendDigit(x) -- concatenate the value in X to the texxt in
// document.forms.kpd.display.value
// ------------------------------------------------------------------------------------------
function AppendDigit(x) {
if (x==".") {
if (!HasDecimal) {
document.forms.kpd.display.value=
document.forms.kpd.display.value + x;
HasDecimal = true;
};
} else {
if {document.forms.kpd.display.value=="0") {
if (x!="0") {
document.forms.kpd.display.value=
document.forms.kpd.display.value + x;
} else {
document.forms.kpd.display.value = x;
};
};
};
}
Here is the HTML which I am still having problems with:
Code:
<html>
<head>
<title>John's Calculator</title>
<style type="text/css">
.rt {text-align:right; font-family: Courier New;}
.numbttn {text-align: center; background-color:
silver; font-family: Courier New; width: 4eM;}
body {background-color: silver}
</style>
<script type="text/javascript" src="cal.js"></script>
</head>
<body>
<form name="kpd">
<tr> <TABLE BORDER=4>
<table border="2" cellpadding="4" cellspacing="0" bordercolor="#000000">
<tr>
<td>
<table border="0" cellpadding="2" cellspacing="0" width="100%">
<tr>
<td colspan="4">
<input type="text" name="calcResults" value="0" size="20" style="text-align: right"></td>
</tr>
<TR>
<TD> <INPUT class="numbttn" TYPE="button" NAME="one" VALUE="1" OnClick="AppendDigit('one')";/></td>
<td> <INPUT class="numbttn" TYPE="button" NAME="two" VALUE="2" OnCLick="AppendDighit('two')";/></td>
<td> <INPUT class="numbttn" TYPE="button" NAME="three" VALUE="3" OnClick="AppedndDigit('three')";/></td>
<td> <INPUT class="numbttn" TYPE="button" NAME="plus" VALUE="+" OnClick="AppendDigit('plus')";/></td>
</tr>
<tr>
<td> <INPUT class="numbttn" TYPE="button" NAME="four" VALUE="4" OnClick="AppendDigit('4')";/></td>
<td> <INPUT class="numbttn" TYPE="button" NAME="five" VALUE="5" OnCLick="AppendDigit('5')";/></td>
<td> <INPUT class="numbttn" TYPE="button" NAME="six" VALUE="6" OnClick="AppendDigit('6')";/></td>
<td> <INPUT class="numbttn" TYPE="button" NAME="minus" VALUE="-" OnClick="AppendDigit(' - ')";/></td>
</tr>
<tr>
<td> <INPUT class="numbttn" TYPE="button" NAME="seven" VALUE="7" OnClick="AppendDigit('7')";/></td>
<td> <INPUT class="numbttn" TYPE="button" NAME="eight" VALUE="8" OnCLick="AppendDigit('8')";/></td>
<td> <INPUT class="numbttn" TYPE="button" NAME="nine" VALUE="9" OnClick="AppendDigit('9')";/></td>
<td> <INPUT class="numbttn" TYPE="button" NAME="times" VALUE="x" OnClick="AppendDigit(' * ')";/></td>
</tr>
<tr>
<td> <Input class="numbttn" TYPE="button" NAME="clear" VALUE="c" OnClick="AppendDigit('')";/></td>
<td> <Input class="numbttn" TYPE="button" NAME="zero" VALUE="0" OnClick="AppendDigit('0')";/></td>
<td> <Input class="numbttn" TYPE="button" NAME="DoIt" VALUE="=" OnClick="AppendDigit('=')";/></td>
<td> <Input class="numbttn"TYPE="button" NAME="div" VALUE="/" OnClick="AppendDigit(' / ');"/></td>
</tr>
</table>
</form>
</body>
</html>
Bookmarks