Store data from the javascript?

Continuing the discussion from Run basic math in real time on a form using JavaScript:

Hi

Instead of an html, I used an input field to display the result of my basic math problem. It is displaying the value of the total on the input field but when I tried to submit the button, it is not recording it.

This is the code:

        var amountInput = $('#'+amountInputId).val();
        var quantityAmount = $('#'+quantityAmountId).val();
        
        var total = amountInput * quantityAmount;
        $("#input_field_id").val(total);

How to store the data from that computation?

Hi @joshjosh

Please try this:

var amountInput = $('#'+amountInputId).val();
var quantityAmount = $('#'+quantityAmountId).val();
    
var total = amountInput * quantityAmount;
$("#input_field_id").val(total).change(); 

I added .change() to the end.

2 Likes

Thank you Moe! Solved :slight_smile: