Solved

# Calculation without refresh

Posted on 2011-05-13
Medium Priority
317 Views
Hi!
I want to make the following calculation page (like shopping card).
My customers need to pay 99\$ setup fee and the hosting for the 1st year will be free.
If they select 2 or more years (with dropdown menu, max 10 years), it needs to calculate 30\$ per each year (need to calculate with jquery or something without refresh).

Example:
Setup: 99\$
Years: 1
Total: 99\$

Example 2:
Setup: 99\$
Years: 2
Total: 129\$

I hope you can help me :)
0
Question by:QuantumBG

LVL 1

Accepted Solution

ggeek earned 500 total points
ID: 35755190
Here is the code:

``````<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<title></title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<body>

<select>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>

<div id="total">99</div>
<script>
\$("select").change(function() {
var num = \$("select").val();
var total = 99 + (num - 1) * 30 + "";
\$("#total").text(total);
})
.change();
</script>

</body>
</html>
``````
0

Author Closing Comment

ID: 35755779
Thank you!
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
###### Suggested Courses
Course of the Month16 days, 17 hours left to enroll