0

How can I get two input box data without submitting form data and add them on a click of a button and show the result in another input box?

     _________________________
ROI:|_________________________|

            _________________________
Princilpe: |_________________________|

       _________________________
Time: |_________________________|

                  _________________________
Compound Intrest:|_________________________|

I want to get the values of ROI, principle amount and time duration and calculate the compound interest and show the result in rate per month input box the result will be generated only after the cal:EMI button is clicked.

3
  • 3
    Show us what you've done so far. Commented Aug 22, 2014 at 12:03
  • onedrive.live.com/… Commented Aug 22, 2014 at 12:14
  • Show us the code you've done so far. Commented Aug 22, 2014 at 12:15

2 Answers 2

1

You can use jquery..like below..

you have to include first main basic jquery file then,

    $(document).ready(function()
{
    $('#compoundinterest').focus(function()
    {
        var p = +$('#principal').val();
        var r = +$('#roi').val();
        var n = +$('#time').val();

        var i = ((p * r * n) / 100);

        $('#compoundinterest').val(i);

    });
});

here #.. shows ids of input boxes.. and '+' is used to convert string into integer..

Sign up to request clarification or add additional context in comments.

Comments

0

Use jQuery or JavaScript

get value from the text field

var variable=$('#input_field_id').val();

do the calculation with the values.

set value to the text field

$('#result_field_id').val(calculated_value);

if You want to related with database then use Ajax

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.