Simple instant price quote calculator javascript

Hi there,

I am trying to come up with an instant price quote calculator in javascript.

Below is a sample of what I need
Price per Meal
Price per Week
Shipping & Handling included
Tax estimated
Total

Please let me know what other information I can provide to create this calculator.

Recommended Answers

All 6 Replies

Not quite understand on your question. Do you mean that all field is provided and the total should be calculated using javascript?

Then what else do you need to know?

I don't know how to write the code.

The thing here is that the site you referenced is using server-side scripting to perform the calculations. If you are going to do this client side, then you'll need to create some javascript functions that accept parameters based on what the user is choosing in the drop down lists, some logic to perform based on the parameters, and update the target element with the results.

Agree with JorgeM.
For example:

<html>
    <head>
    <script src='http://code.jquery.com/jquery.min.js'></script>
    <script>
        jQuery(document).ready(function(){
            jQuery('.price').live('keyup',function(){
                var total = parseInt(jQuery(this).val());
                var sib = jQuery(this).siblings('.price')
                jQuery.each(sib,function(){
                    total = total + parseInt(jQuery(this).val());
                })
                jQuery('#total').text(total);
            })
        })
    </script>
    </head>
    <body>
    <label>price1</label><input type="text" id="price1" class="price" value=""/>
    <label>price2</label><input type="text" id="price2" class="price" value=""/>
    <label>price3</label><input type="text" id="price3" class="price" value=""/>
    <div>Total=<span id="total"></span></div>
    </body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.