Question:

Code for java script calculation

by  |  earlier

0 LIKES UnLike

hi friends..,

please get me the java script code for shopping cart price calculation

 Tags:

   Report

2 ANSWERS


  1. I have no idea what you would want it to look like but you could tweak this HTML/Javascript to your needs I guess...

    <html>

    <head>

    <script>

    function calc() {

        one = document.getElementById('one').value;

        two = document.getElementById('two').value;

    if(one=='Price 1') {

    one = 0;

    }

    if(two=='Price 2') {

    two = 0;

    }

        answer = one*1 + two*1;

        document.getElementById('ans').innerHTML = answer;

    }

    </script>

    </head>

    <body>

    <input type="text" id="one" value="Price 1" onFocus="if(this.value=='Price 1'){this.value=''};" onBlur="if(this.value==''){this.value='P... 1'};" />

    <input type="text" id="two" value="Price 2" onFocus="if(this.value=='Price 2'){this.value=''};" onBlur="if(this.value==''){this.value='P... 2'};" />

    <input type="button" value="Calculate" onClick="calc()" />

    <p id="ans"></p>

    </body>

    </html>


  2. It would be much easier to help if you had something to start with for people to look at and help critique your code.

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.