aqui les dejo el codigo:
- Código:
<form action name="Keypad"> <b> <div align="center"> <table border="2" cellpadding="1" cellspacing="5" height="60" width="50"> <tbody> <tr> <td align="middle" colspan="3"><input name="ReadOut" size="24" value="0" width="100%" style="text-align: right" /></td> <td> </td> <td align="center"><input name="btnClear" onclick="Clear()" type="button" value=" C " /></td> <td align="center"><input name="btnClearEntry" onclick="ClearEntry()" type="button" value=" CE " /></td> </tr> <tr> <td align="center"><input name="btnSeven" onclick="NumPressed(7)" type="button" value=" 7 " /></td> <td align="center"><input name="btnEight" onclick="NumPressed(8)" type="button" value=" 8 " /></td> <td align="center"><input name="btnNine" onclick="NumPressed(9)" type="button" value=" 9 " /></td> <td align="center"> </td> <td align="center"><input name="btnNeg" onclick="Neg()" type="button" value=" +/- " /></td> <td align="center"><input name="btnPercent" onclick="Percent()" type="button" value=" % " /></td> </tr> <tr> <td align="center"><input name="btnFour" onclick="NumPressed(4)" type="button" value=" 4 " /></td> <td align="center"><input name="btnFive" onclick="NumPressed(5)" type="button" value=" 5 " /></td> <td align="center"><input name="btnSix" onclick="NumPressed(6)" type="button" value=" 6 " /></td> <td align="center"> </td> <td align="center"><input name="btnPlus" onclick="Operation('+')" type="button" value=" + " /></td> <td align="center"><input name="btnMinus" onclick="Operation('-')" type="button" value=" - " /></td> </tr> <tr> <td align="center"><input name="btnOne" onclick="NumPressed(1)" type="button" value=" 1 " /></td> <td align="center"><input name="btnTwo" onclick="NumPressed(2)" type="button" value=" 2 " /></td> <td align="center"><input name="btnThree" onclick="NumPressed(3)" type="button" value=" 3 " /></td> <td align="center"> </td> <td align="center"><input name="btnMultiply" onclick="Operation('*')" type="button" value=" * " /></td> <td align="center"><input name="btnDivide" onclick="Operation('/')" type="button" value=" / " /></td> </tr> <tr> <td align="center"><input name="btnZero" onclick="NumPressed(0)" type="button" value=" 0 " /></td> <td align="center"><input name="btnDecimal" onclick="Decimal()" type="button" value=" . " /></td> <td colspan="3" align="center"> </td> <td align="center"><input name="btnEquals" onclick="Operation('=')" type="button" value=" = " /></td> </tr> </tbody> </table> </div> </b> </form> <script language="JavaScript"> <!-- modifica este script para tu uso --> <!-- puedes cambiar tamaño y color de botones y fondo --> <!-- Begin var FKeyPad = document.Keypad; var Accum = 0; var FlagNewNum = false; var PendingOp = ""; function NumPressed (Num) { if (FlagNewNum) { FKeyPad.ReadOut.value = Num; FlagNewNum = false; } else { if (FKeyPad.ReadOut.value == "0") FKeyPad.ReadOut.value = Num; else FKeyPad.ReadOut.value += Num; } } function Operation (Op) { var Readout = FKeyPad.ReadOut.value; if (FlagNewNum && PendingOp != "="); else { FlagNewNum = true; if ( '+' == PendingOp ) Accum += parseFloat(Readout); else if ( '-' == PendingOp ) Accum -= parseFloat(Readout); else if ( '/' == PendingOp ) Accum /= parseFloat(Readout); else if ( '*' == PendingOp ) Accum *= parseFloat(Readout); else Accum = parseFloat(Readout); FKeyPad.ReadOut.value = Accum; PendingOp = Op; } } function Decimal () { var curReadOut = FKeyPad.ReadOut.value; if (FlagNewNum) { curReadOut = "0."; FlagNewNum = false; } else { if (curReadOut.indexOf(".") == -1) curReadOut += "."; } FKeyPad.ReadOut.value = curReadOut; } function ClearEntry () { FKeyPad.ReadOut.value = "0"; FlagNewNum = true; } function Clear () { Accum = 0; PendingOp = ""; ClearEntry(); } function Neg () { FKeyPad.ReadOut.value = parseFloat(FKeyPad.ReadOut.value) * -1; } function Percent () { FKeyPad.ReadOut.value = (parseFloat(FKeyPad.ReadOut.value) / 100) * parseFloat(Accum); } // End --> </script>