Welcome Guest, Not a member yet? Register   Sign In
calculating values based on the form input

(This post was last modified: 08-20-2018, 04:26 AM by Marcel.)

Yes JS is the Way to go

here is a small snippet that should get you going.
Carefull, this is far from professional quality code just a basic implementation using jquery.

<script src="//ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<input type="text" name="value1" id="textone">
<input type="text" name="value2" id="texttwo">
<input type="text" name="result" id="result">

       var textone;
       var texttwo;
       textone = parseFloat($('#textone').val());
       texttwo = parseFloat($('#texttwo').val());
       var result = textone + texttwo;

here is a pure javascript example (no jquery needed).

<input type="text" id="textone"  onkeyup="sum();" />
<input type="text" id="texttwo"  onkeyup="sum();" />
<input type="text" id="textthree" />

function sum() {
           var txtFirstNumberValue = document.getElementById('textone').value;
           var txtSecondNumberValue = document.getElementById('texttwo').value;
           var result = parseInt(txtFirstNumberValue) + parseInt(txtSecondNumberValue);
           if (!isNaN(result)) {
               document.getElementById('textthree').value = result;

Messages In This Thread
RE: calculating values based on the form input - by Marcel - 08-20-2018, 04:19 AM

Theme © iAndrew 2016 - Forum software by © MyBB