Addition and Multiplication help

Addition and Multiplication help

Hello all,

Currently this script is outputting the exact mathematical calculations I need it to perform. Can someone show me how to change these from simply outputting formulas to actually executing them?

Current example output: "Values added together and multiplied by the variable: 4 + 6 X 5"
Desired output:  "Values added together and multiplied by the variable: 50"

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
  6. <script src="jquery-ui-1.8.22.custom.min.js" type="text/javascript"></script>
  7. <link rel="stylesheet" href="css/ui-lightness/jquery-ui-1.8.22.custom.css">
  8. <script>
  9. $(function() {
  10. var valueMultiplier = '5';
  11. $( "#slider" ).slider({
  12. value:1,
  13. min: 1,
  14. max: 12,
  15. step: 1,
  16. slide: function( event, ui ) {
  17. if(ui.value > 1){
  18. $( "#amount" ).val( + ui.value );
  19. $( "#amountthree" ).val($("#amount").val() + " + " + $("#amounttwo").val() + "");
  20. $( "#amountfour" ).val($("#amount").val() + " + " + $("#amounttwo").val() + " X " + valueMultiplier);
  21. }else{
  22. $( "#amount" ).val( + ui.value + " month" );
  23. $( "#amountthree" ).val($("#amount").val() + " + " + $("#amounttwo").val() + "");
  24. $( "#amountfour" ).val($("#amount").val() + " + " + $("#amounttwo").val() + " X " + valueMultiplier);
  25. }
  26. }
  27. });
  28. $( "#amount" ).val($( "#slider" ).slider( "value" ));
  29. $( "#slidertwo" ).slider({
  30. value:1,
  31. min: 3,
  32. max:36,
  33. step: 3,
  34. slide: function( event, ui ) {
  35. if(ui.value > 1){
  36. $( "#amounttwo" ).val( + ui.value);
  37. //$( "#amountthree" ).val( + ui.value + PREVIOUS SLIDER UI VALUE HERE + " months" );
  38. $( "#amountthree" ).val($("#amount").val() + " + " + $("#amounttwo").val() + "");
  39. $( "#amountfour" ).val($("#amount").val() + " + " + $("#amounttwo").val() + " X " + valueMultiplier);
  40. }else{
  41. $( "#amounttwo" ).val( + ui.value + " month" );
  42. $( "#amountthree" ).val($("#amount").val() + " + " + $("#amounttwo").val() + "");
  43. $( "#amountfour" ).val($("#amount").val() + " + " + $("#amounttwo").val() + " X " + valueMultiplier);
  44. }
  45. }
  46. });
  47. $( "#amounttwo" ).val($( "#slidertwo" ).slider( "value" ));
  48. $( "#amountthree" ).val($( "#slidertwo" ).slider( "value" ) + $( "#slider").slider( "value" ));
  49. $( "#amountfour" ).val($( "#slidertwo" ).slider( "value" ) + $( "#slider").slider( "value" ) + " X " + valueMultiplier);
  50. });
  51. </script>
  52. </head>

  53. <body>
  54. <p>
  55. <label for="amount">Value One?:</label>
  56. <input type="text" id="amount" style="border:0; color:#f6931f; font-weight:bold;" />
  57. </p>

  58. <div id="slider"></div>

  59. <p>
  60. <label for="amounttwo">Value Two?:</label>
  61. <input type="text" id="amounttwo" style="border:0; color:#f6931f; font-weight:bold;" />
  62. </p>
  63. <div id="slidertwo"></div>

  64. <p class="holder">Values added together: <input type="text" id="amountthree" style="border:0; color:#f6931f; font-weight:bold;" /> </p>
  65. <p class="holder">Values added together and multiplied by the variable: <input type="text" id="amountfour" style="border:0; color:#f6931f; font-weight:bold;" /> </p>
  66. </body>
  67. </html>