Tell me more ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I want to make calculator for summation.

I have this jquery code:

 <script type="text/javascript">

 $(document).ready(function() {

     $("#calculate").click(function() {

    if ($("#input").val() != '' && $("#input").val() != undefined) {

        $("#result").html("Result is: " + parseInt($("#input").val()) * 30 );

         }

         else
         {
             $("#result").html("Please enter some value");
         }
    }); });

 </script>

<div id="calculator">
    <br />
    <input type="text" style="left:20px;" id="input" />
    <div id="result"></div>
    <input type="button" id="calculate" value="calculate" style="left:20px;" /> 
</div>

I want something like this:

I write number 5, then input + from keyboard and write another value.

Then to click on summation button and to get value.

Can anyone help me with this?

Thank you very much!

share|improve this question
i think you may have better luck with this over on stackoverflow, perhaps make a js fiddle and post it on there – sam Oct 21 '12 at 13:41
I would have migrated this question to Stack Overflow, but they already have a lot of questions about jquery calculators over there: stackoverflow.com/search?q=jquery+calculator&submit=search – Christofian Oct 21 '12 at 16:30
1  
Has this been set as an assignment? Two questions on JavaScript calculators in the same day? – w3d Oct 21 '12 at 16:42

closed as off topic by Su', Christofian Oct 21 '12 at 16:29

Questions on Webmasters Stack Exchange are expected to relate to webmastering within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.

1 Answer

jQuery calculators are pretty common, here are two which should help you with your code

http://www.pengoworks.com/workshop/jquery/calculation/calculation.plugin.htm

and

http://codevisually.com/blackcalculator-a-customizable-jquery-calculator/

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.