|
|
Subject:
Why doesn't the "C" key work on this java calculator?
Category: Computers > Algorithms Asked by: lampware-ga List Price: $2.00 |
Posted:
10 Sep 2004 20:30 PDT
Expires: 10 Oct 2004 20:30 PDT Question ID: 399617 |
<html> <head> <title> Java Simple Calculator </title> <style> body, tr, td, input: {font-family:Fixed; color:blue} </style> <script language="JavaScript"> <!-- string=""; function app( cc ) { string += cc; document.form1.text1.value = string; } function clear( ) { string = ""; document.form1.text1.value = string; } function calc( ) { if( string.length > 0 ) { inp = "out=" + string; eval( inp ); } else out = "0"; document.form1.text1.value = out; string = "" + out; } function upda( ) { string = "" + document.form1.text1.value; } //--> </script> </head> <body onLoad="clear()"> <form name="form1" method="POST" onSubmit="{upda(); calc(); return false;}"> <table border> <tr> <td colspan=5> <input type="text" style="font-family:Courier" size=18 maxlength=80 name="text1" value="" onChange="upda()"> </td> </tr> <tr> <td align=center> <input type="button" style="font-family:Courier" value=" 7 " onClick="app('7')"> </td> <td align=center> <input type="button" style="font-family:Courier" value=" 8 " onClick="app('8')"> </td> <td align=center> <input type="button" style="font-family:Courier" value=" 9 " onClick="app('9')"> </td> <td align=center> <input type="button" style="font-family:Courier" value=" / " onClick="app('/')"> </td> <td align=center> <input type="button" style="font-family:Courier" value=" C " onClick="clear()"> </td> </tr> <tr> <td align=center> <input type="button" style="font-family:Courier" value=" 4 " onClick="app('4')"> </td> <td align=center> <input type="button" style="font-family:Courier" value=" 5 " onClick="app('5')"> </td> <td align=center> <input type="button" style="font-family:Courier" value=" 6 " onClick="app('6')"> </td> <td align=center> <input type="button" style="font-family:Courier" value=" * " onClick="app('*')"> </td> <td align=center> <input type="button" style="font-family:Courier" value=" ( " onClick="app('(')"> </td> </tr> <tr> <td align=center> <input type="button" style="font-family:Courier" value=" 1 " onClick="app('1')"> </td> <td align=center> <input type="button" style="font-family:Courier" value=" 2 " onClick="app('2')"> </td> <td align=center> <input type="button" style="font-family:Courier" value=" 3 " onClick="app('3')"> </td> <td align=center> <input type="button" style="font-family:Courier" value=" - " onClick="app('-')"> </td> <td align=center> <input type="button" style="font-family:Courier" value=" ) " onClick="app(')')"> </td> </tr> <tr> <td align=center> <input type="button" style="font-family:Courier" value=" 0 " onClick="app('0')"> </td> <td> </td> <td align=center> <input type="button" style="font-family:Courier" value=" . " onClick="app('.')"> </td> <td align=center> <input type="button" style="font-family:Courier" value=" + " onClick="app('+')"> </td> <td align=center> <input type="button" style="font-family:Courier" value=" = " onClick="calc()"> </td> </tr> </table> </form> <body> </html> |
|
Subject:
Re: Why doesn't the "C" key work on this java calculator?
Answered By: googleexpert-ga on 10 Sep 2004 21:03 PDT |
Hi, There seems to be a function name conflict between your "clear()" and Javascript's "clear()" If you change your function "clear()" to something else like "fieldclear()", it your calculator should work. Reference: http://www.mozilla.org/docs/dom/domref/dom_doc_ref42.html Please let me know if you have anymore questions. -googleexpert |
|
There are no comments at this time. |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |