Jump to content

Ayman_Khoshouey

Members
  • Content Count

    1
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Ayman_Khoshouey

  • Rank
    Newbie

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. what is error of this? It give me wrong results <html> <head> <title>Calculator</title> <script language='JavaScript'> var number='0'; var start=0; var firstNumber=0; var result=0; var sign=''; calculator.results.value='0' function show(number,sign){ if (sign !=''){ calculator.results.value=''; calculator.results.value=number; } else{ calculator.results.value=calculator.results.value+number; } //start++ } function add(){ sign='+'; firstNumber=parseFloat(calculator.results.value); calculator.results.value=''; } function subtract(){ sign='-'; firstNumber=parseFloat(calculator.results.value); calculator.results.value=''; } function equal(sign){ if (sign='+'){ result=parseFloat(calculator.results.value)+firstNumber; calculator.results.value=result; } if (sign='-'){ result=firstNumber-parseFloat(calculator.results.value); calculator.results.value=result; } } </script> </head> <body> <form name="calculator"> Calculator <br/> <input type="text" name="results" value="" /> <br/> <br/> <input type="button" value="1" onclick="show('1','')" /> <input type="button" value="2" onclick="show('2','')" /> <input type="button" value="3" onclick="show('3','')" /> <br/> <input type="button" value="4" onclick="show('4','')" /> <input type="button" value="5" onclick="show('5','')" /> <input type="button" value="6" onclick="show('6','')" /> <br/> <input type="button" value="7" onclick="show('7','')" /> <input type="button" value="8" onclick="show('8','')" /> <input type="button" value="9" onclick="show('9','')" /> <br/> <input type="button" value="+" onclick="add()" /> <input type="button" value="-" onclick="subtract()" /> <input type="button" value="=" onclick="equal(sign)" /> <br/> </form> </body> </html>
×
×
  • Create New...