JavaScript Can't get Jquery to write the output of a function to html canvas,canada,cancelled,canceled vs cancelled,cancun,canada goose,cane

new guy here. I have a feeling this is an extremely basic question but I can't get this Jquery code to write the output of the function to html and have it show up. I believe it's an issue with the script but unsure if I am doing something wrong with html as well.

The goal of this function is to create a calculator that gives future investment value based on what the user inputs. When I click submit, It used to change all of the html to show just 'NaN' but now when I click the submit button, it clears the input boxes but does not give me any number or any answer even though I believe I've set it to display the number to

HTML

<body>
    <div id = "futurevalue">
        <form>
            <input type="radio" name="formula" value="future_investment" checked>Future Investment<br>
            <label for="princeple">Enter the princeple amount invested:</label>
            <input id="princeple" type="number" name="princeple" step="0.01"><br>
            <label for="time">Enter how long the investment will be for (in years):</label>
            <input id='time' type='number' name='time'><br>
            <label for='rate'>Enter the expected interest rate:</label>
            <input id='rate' type="number" name='rate'><br>
            <input id='submit' type='submit' name='submit'>
        </form>
        <p>Total:</p>
        <p id='result'></p>
    </div>

jQuery

 $('#submit').click(function(){
    $('#result').html(function(){
        return toString(output,10);
    });
});
var princeple = parseInt($('#princeple'),10);  
var time = parseInt($('#time'),10);
var rate = parseInt($('#rate'),10);
var output = (princeple * time + rate);
Answer:1

Here is your fix:

$('#submit').click(function(){
  var princeple = parseInt($('#princeple').val());  
  var time = parseInt($('#time').val());
  var rate = parseFloat($('#rate').val()/100);
  var output = ((princeple * rate) * time);
  $('#result').html(output);
  //prevent from page reload
  return false;
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id = "futurevalue">
        <form>
            <input type="radio" name="formula" value="future_investment" checked>Future Investment<br>
            <label for="princeple">Enter the princeple amount invested:</label>
            <input id="princeple" type="number" name="princeple" step="0.01"><br>
            <label for="time">Enter how long the investment will be for (in years):</label>
            <input id='time' type='number' name='time'><br>
            <label for='rate'>Enter the expected interest rate:</label>
            <input id='rate' type="number" name='rate'><br>
            <input id='submit' type='submit' name='submit'>
        </form>
        <p>Total:</p>
        <p id='result'></p>
    </div>
Answer:2

I have a report with checkboxes in each row and one submit button. I want to disable button when all checkboxes are unchecked. Button should be only enabled when at least one checkbox is checked on ...

I have a report with checkboxes in each row and one submit button. I want to disable button when all checkboxes are unchecked. Button should be only enabled when at least one checkbox is checked on ...

  1. disabled enabled button jquery
  2. disabled enabled button javascript
  3. disabled enabled button css
  4. enable disable button
  5. enable disabled button html

I have a minified app.min.js file which is ~ 80Kb big and contains all javascript code my website requires. If I include this file as script with source pointing to app.min.js everything works fine, ...

I have a minified app.min.js file which is ~ 80Kb big and contains all javascript code my website requires. If I include this file as script with source pointing to app.min.js everything works fine, ...

  1. jade minify javascript

In my script I am loading an image from an array into a div, then I calculate some style elements to be tuned. The problem is that this works only if I use a timeout function before calculating the ...

In my script I am loading an image from an array into a div, then I calculate some style elements to be tuned. The problem is that this works only if I use a timeout function before calculating the ...

This might be a question more for Jasmine or Angular, but I’m wondering how to use the Loopback-generated Angular services in my tests. I don’t need to test the services themselves, but I need to test ...

This might be a question more for Jasmine or Angular, but I’m wondering how to use the Loopback-generated Angular services in my tests. I don’t need to test the services themselves, but I need to test ...

  1. loopback services angular