Calculation without refresh

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 :)
QuantumBGAsked:
Who is Participating?
 
ggeekConnect With a Mentor Commented:
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">
<head>
    <title></title>
</head>
<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>

Open in new window

0
 
QuantumBGAuthor Commented:
Thank you!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.