The calculator above doesn't seem to work for me.
However, I can make a couple of suggestions that think will help you a long the way.
A) Please don't take this the wrong way. Part of programming is resolving the issues that you are having -- that is the fun of it. Gets more fun when your under pressure of deadlines.
B) I would recommend using jQuery. You will inherently learn javascript.
C) Finally, use div tags to write the validated key press to read from that separating the values by operators.
eg:
com/tag/calculation">calculation=$('#output_div_id').val();
com/tag/calculation">calculation_parts = com/tag/calculation">calculation.split('+');
answer = parseInt(com/tag/calculation">calculation_part[0]) + parseInt(com/tag/calculation">calculation_part[1]).
$('#output_div_id').html($('#output_div_id').html()+ "=" + answer);
Hope that helps - good luck with learning java
manpreet
Best Answer
2 years ago
I am working on a calculator program to practice and aid in learning javascript. I have this so far: