Kode for Calculator
<form name="Calc" action=""><div><input type="text" name="Input" size="10" /></div><input type="button" name="one" value="1" onclick="Calc.Input.value += '1'" /> <input type="button" name="two" value="2" onclick="Calc.Input.value += '2'" /> <input type="button" name="three" value="3" onclick="Calc.Input.value += '3'" /> <input type="button" name="plus" value="+" onclick="Calc.Input.value += ' + '" /><br /><input type="button" name="four" value="4" onclick="Calc.Input.value += '4'" /> <input type="button" name="five" value="5" onclick="Calc.Input.value += '5'" /> <input type="button" name="six" value="6" onclick="Calc.Input.value += '6'" /> <input type="button" name="minus" value="-" onclick="Calc.Input.value += ' - '" /><br /><input type="button" name="seven" value="7" onclick="Calc.Input.value += '7'" /> <input type="button" name="eight" value="8" onclick="Calc.Input.value += '8'" /> <input type="button" name="nine" value="9" onclick="Calc.Input.value += '9'" /> <input type="button" name="times" value="x" onclick="Calc.Input.value += ' * '" /><br /><input type="button" name="clear" value="C" style="color:red" onclick="Calc.Input.value = ''" /> <input type="button" name="zero" value="0" onclick="Calc.Input.value += '0'" /> <input type="button" name="comp" value="="onclick="Calc.Input.value = eval(Calc.Input.value)" /> <input type="button" name="div" value="/" onclick="Calc.Input.value += ' / '" /></form>
Kode Kalkulator
<form name="kalkulator"><table width="222" bgcolor="#AA6600" border="3" bordercolor="#555" cellpadding="1" cellspacing="2"><tbody><tr><td><input size="25" length="25" value="" name="ans" style="background: none repeat scroll 0% 0% beige; -moz-background-inline-policy: continuous; color: black;" type="text"></td></tr></tbody></table><table width="222" bgcolor="#AA6600" border="3" bordercolor="#555" cellpadding="2" cellspacing="2"><tbody><tr><td align="center"><input onclick="document.kalkulator.ans.value+='7'" value="7" name="seven" type="button"></td><td align="center"><input onclick="document.kalkulator.ans.value+='8'" value="8" name="eight" type="button"></td><td align="center"><input onclick="document.kalkulator.ans.value+='9'" value="9" name="nine" type="button"></td><td align="center"><input onclick="document.kalkulator.ans.value+='/'" value="/" name="divide" type="button"></td></tr><tr><td align="center"><input onclick="document.kalkulator.ans.value+='4'" value="4" name="four" type="button"></td><td align="center"><input onclick="document.kalkulator.ans.value+='5'" value="5" name="five" type="button"></td><td align="center"><input onclick="document.kalkulator.ans.value+='6'" value="6" name="six" type="button"></td><td align="center"><input onclick="document.kalkulator.ans.value+='*'" value="*" name="multiply" type="button"></td></tr><tr><td align="center"><input onclick="document.kalkulator.ans.value+='1'" value="1" name="one" type="button"></td><td align="center"><input onclick="document.kalkulator.ans.value+='2'" value="2" name="two" type="button"></td><td align="center"><input onclick="document.kalkulator.ans.value+='3'" value="3" name="three" type="button"></td><td align="center"><input onclick="document.kalkulator.ans.value+='-'" value="-" name="subtract" type="button"></td></tr><tr><td align="center"><input onclick="document.kalkulator.ans.value=''" value="C" name="clear" type="button"></td><td align="center"><input onclick="document.kalkulator.ans.value+='0'" value="0" name="zero" type="button"></td><td align="center"><input onclick="document.kalkulator.ans.value=eval(document.kalkulator.ans.value)" value="=" name="equal" type="button"></td><td align="center"><input onclick="document.kalkulator.ans.value+='+'" value="+" name="add" type="button"></td></tr></tbody></table></form>
Bye...bye :-h
Tidak ada komentar:
Posting Komentar