How to calculate two input form fields and put the value in another without submitting the form using jquery?

facemoi

I know this is an extremely basic question but I'm stuck on this. I have two input boxes and I want to calculate those inputs and show the result into another input (3rd one) immediately without the need of a submit button. I means, once I start entering the values into the input and the result will shows live in the 3rd input which is the represent the result...

<input type="text" class="input value1">
<input type="text" class="input value2">
<input type="text" disabled="disabled" id="result">

<script>
 $(document).ready(function(){
      var val1 = $(".value1").val();
      var val2 = $(".value2").val();
      $(".input").keyup(function(){
         $("#result").text(val1+val2);
       });
});
</script>
Artem Fitiskin

Put val1 and val2 in keyup statement.

$(document).ready(function(){
    $(".input").keyup(function(){
          var val1 = +$(".value1").val();
          var val2 = +$(".value2").val();
          $("#result").val(val1+val2);
    });
});

Look at fiddle: http://jsfiddle.net/g7zz6/

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to calculate two input form fields and put the value in another without submitting the form using jquery with JSF

From Dev

Form submitting using jquery without ajax in rails

From Dev

Submitting a form with JQuery - Required Fields

From Dev

How to make HTML form input fields responsive without using Bootstrap

From Dev

How do I post form data without submitting the form with jQuery?

From Dev

How to update two fields in mysql using php via a input form

From Dev

How to check calculation answer of 2 input fields before submitting form

From Dev

How to detect a change in any of a form's input fields using jQuery?

From Dev

Submitting a large form using jQuery ajax, without using serialize()

From Dev

Issue on Submitting a Form using jQuery

From Dev

How to get the input value after submitting the form in jsf ?

From Dev

How to get text value by pressing enter on keyboard without submitting the form

From Dev

Form is submitting to another page without validation in php

From Dev

How to send data to servlet using ajax without a submitting form

From Dev

How to get value of fields in a repeating form with jQuery?

From Dev

adding an input value and submitting the form on load

From Dev

jQuery wrap div with form without submitting

From Dev

Move a value to another form using jQuery

From Dev

JQuery update input value based on another form input

From Dev

How to calculate form fields values to update hidden field value?

From Dev

How to set a input value of a form with jQuery Cookie

From Dev

How to pass form input fields to another component in React?

From Dev

jQuery to append input of dynamically loaded Ajax select list to another form before submitting

From Dev

Form with two inputs not submitting?

From Dev

Submitting a form using jQuery and Ajax changing the action

From Dev

Confirmation before submitting form using jQuery

From Dev

Submitting a form with a file using JQuery and AJAX

From Dev

Submitting form by jquery using method=post

From Dev

Submitting a form with a file using JQuery and AJAX

Related Related

  1. 1

    How to calculate two input form fields and put the value in another without submitting the form using jquery with JSF

  2. 2

    Form submitting using jquery without ajax in rails

  3. 3

    Submitting a form with JQuery - Required Fields

  4. 4

    How to make HTML form input fields responsive without using Bootstrap

  5. 5

    How do I post form data without submitting the form with jQuery?

  6. 6

    How to update two fields in mysql using php via a input form

  7. 7

    How to check calculation answer of 2 input fields before submitting form

  8. 8

    How to detect a change in any of a form's input fields using jQuery?

  9. 9

    Submitting a large form using jQuery ajax, without using serialize()

  10. 10

    Issue on Submitting a Form using jQuery

  11. 11

    How to get the input value after submitting the form in jsf ?

  12. 12

    How to get text value by pressing enter on keyboard without submitting the form

  13. 13

    Form is submitting to another page without validation in php

  14. 14

    How to send data to servlet using ajax without a submitting form

  15. 15

    How to get value of fields in a repeating form with jQuery?

  16. 16

    adding an input value and submitting the form on load

  17. 17

    jQuery wrap div with form without submitting

  18. 18

    Move a value to another form using jQuery

  19. 19

    JQuery update input value based on another form input

  20. 20

    How to calculate form fields values to update hidden field value?

  21. 21

    How to set a input value of a form with jQuery Cookie

  22. 22

    How to pass form input fields to another component in React?

  23. 23

    jQuery to append input of dynamically loaded Ajax select list to another form before submitting

  24. 24

    Form with two inputs not submitting?

  25. 25

    Submitting a form using jQuery and Ajax changing the action

  26. 26

    Confirmation before submitting form using jQuery

  27. 27

    Submitting a form with a file using JQuery and AJAX

  28. 28

    Submitting form by jquery using method=post

  29. 29

    Submitting a form with a file using JQuery and AJAX

HotTag

Archive