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"
- <!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>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
- <script src="jquery-ui-1.8.22.custom.min.js" type="text/javascript"></script>
- <link rel="stylesheet" href="css/ui-lightness/jquery-ui-1.8.22.custom.css">
- <script>
- $(function() {
-
- var valueMultiplier = '5';
-
- $( "#slider" ).slider({
- value:1,
- min: 1,
- max: 12,
- step: 1,
- slide: function( event, ui ) {
- if(ui.value > 1){
- $( "#amount" ).val( + ui.value );
- $( "#amountthree" ).val($("#amount").val() + " + " + $("#amounttwo").val() + "");
- $( "#amountfour" ).val($("#amount").val() + " + " + $("#amounttwo").val() + " X " + valueMultiplier);
- }else{
- $( "#amount" ).val( + ui.value + " month" );
- $( "#amountthree" ).val($("#amount").val() + " + " + $("#amounttwo").val() + "");
- $( "#amountfour" ).val($("#amount").val() + " + " + $("#amounttwo").val() + " X " + valueMultiplier);
- }
- }
- });
- $( "#amount" ).val($( "#slider" ).slider( "value" ));
- $( "#slidertwo" ).slider({
- value:1,
- min: 3,
- max:36,
- step: 3,
- slide: function( event, ui ) {
- if(ui.value > 1){
- $( "#amounttwo" ).val( + ui.value);
- //$( "#amountthree" ).val( + ui.value + PREVIOUS SLIDER UI VALUE HERE + " months" );
- $( "#amountthree" ).val($("#amount").val() + " + " + $("#amounttwo").val() + "");
- $( "#amountfour" ).val($("#amount").val() + " + " + $("#amounttwo").val() + " X " + valueMultiplier);
- }else{
- $( "#amounttwo" ).val( + ui.value + " month" );
- $( "#amountthree" ).val($("#amount").val() + " + " + $("#amounttwo").val() + "");
- $( "#amountfour" ).val($("#amount").val() + " + " + $("#amounttwo").val() + " X " + valueMultiplier);
- }
- }
- });
- $( "#amounttwo" ).val($( "#slidertwo" ).slider( "value" ));
- $( "#amountthree" ).val($( "#slidertwo" ).slider( "value" ) + $( "#slider").slider( "value" ));
- $( "#amountfour" ).val($( "#slidertwo" ).slider( "value" ) + $( "#slider").slider( "value" ) + " X " + valueMultiplier);
-
- });
- </script>
- </head>
- <body>
- <p>
- <label for="amount">Value One?:</label>
- <input type="text" id="amount" style="border:0; color:#f6931f; font-weight:bold;" />
-
- </p>
- <div id="slider"></div>
- <p>
- <label for="amounttwo">Value Two?:</label>
- <input type="text" id="amounttwo" style="border:0; color:#f6931f; font-weight:bold;" />
- </p>
- <div id="slidertwo"></div>
- <p class="holder">Values added together: <input type="text" id="amountthree" style="border:0; color:#f6931f; font-weight:bold;" /> </p>
- <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>
- </body>
- </html>