Calculate and submit form values with jquery and ajax and add calculated values to specific div

mickbrancco

I can not figure out how to calculate different form values and submit calculated values to an empty div on another page. I don't have any php or similar, this should be just a dummy page.

Any help would be appreciated.

Here's my current html and jquery code:

HTML:

<form class="wrapper" id="form" action="" name="">
    <input class="input" type="range" min="18" max="90" value="22" id="age" data-amount>
    <select class="input" name="" id="" data-amount>
        <option value="50">Old</option>
    </select>
    <input class="input" type="radio" name="" value="40" id="" data-amount>   
    <input class="button" type="submit" value="Find best match">
</form>

jQuery:

$(document).ready(function() {
    $('#form').submit(function(e){
    e.preventDefault();

    var total = 0;
    var amount = '[data-amount]';

    $(amount).each(function(index){
        total += parseInt($(this).val());
    });

    $.ajax({
        cache: false,
        url: "result.html",
        amount: total,
        success: function(html) {
            $('#result').html(html);
        }
    });
    return false;
    })
});
Keerthi Kumar P

This should probably work and satisfy your need. Not tested though:

HTML:

<form class="wrapper" id="form" action="" name="">
    <input class="input" type="range" min="18" max="90" value="22" id="age" data-amount>
    <select class="input" name="" id="" data-amount>
        <option value="50">Old</option>
    </select>
    <input class="input" type="radio" name="" value="40" id="" data-amount>   
    <input class="button" type="submit" value="Find best match">
</form>
<div id="result-container" style="display:none">
</div>

jQuery:

$(document).ready(function() {
    $('#form').submit(function(e){
    e.preventDefault();

    var total = 0;
    var amount = '[data-amount]';

    $(amount).each(function(index){
        total += parseInt($(this).val());
    });

    $("#result-container").html(total);
    $("#result-container").show();
    $("form").hide();
    return false;
    })
});

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Submit multiple values of a form using AJAX (but no jQuery) - XMLHttpRequest

From Dev

Calculate mean of calculated values

From Dev

Dynamic form for submit values

From Javascript

jQuery AJAX submit form

From Dev

jQuery(ajax) submit form

From Dev

Submit form with data values inserted from AJAX in Laravel

From Dev

Calculate specific Values

From Dev

How to add values/names of checkbox to a variable on form submit?

From Dev

jquery form only passing first select box values on submit

From Javascript

How to use jquery $.post() method to submit form values

From Dev

Submit Form and return values using HTML / JQuery / PHP

From Dev

Input values from jQuery not being picked up on form submit

From Dev

How to submit attr value and form values with POST using JQuery and PHP?

From Dev

Symfony - PHPunit Submit form with jquery-generation of values (for selects)

From Dev

Django: jQuery to trigger a form submit onchange of checkbox and retain the values on the reload

From Dev

Submit multiple form values with AngularFire

From Dev

Django Form submit manipulate values

From Dev

ReactJS Submit form with default values

From Dev

Pass values to $('form').submit(function ()

From Dev

How to get form values on submit?

From Dev

Submit a Form Using Jquery Ajax

From Dev

jQuery ajax Form Submit - how to?

From Dev

Ajax submit form with jquery not validating

From Dev

Using Ajax to submit form Jquery

From Dev

jquery ajax form submit is not working

From Dev

how to submit the form values using ajax call, without using submit button

From Dev

Add input into form with jquery and submit

From Dev

add calculated column to pandasdataframe depending on NULL values

From Dev

Postgres add column with initially calculated values

Related Related

  1. 1

    Submit multiple values of a form using AJAX (but no jQuery) - XMLHttpRequest

  2. 2

    Calculate mean of calculated values

  3. 3

    Dynamic form for submit values

  4. 4

    jQuery AJAX submit form

  5. 5

    jQuery(ajax) submit form

  6. 6

    Submit form with data values inserted from AJAX in Laravel

  7. 7

    Calculate specific Values

  8. 8

    How to add values/names of checkbox to a variable on form submit?

  9. 9

    jquery form only passing first select box values on submit

  10. 10

    How to use jquery $.post() method to submit form values

  11. 11

    Submit Form and return values using HTML / JQuery / PHP

  12. 12

    Input values from jQuery not being picked up on form submit

  13. 13

    How to submit attr value and form values with POST using JQuery and PHP?

  14. 14

    Symfony - PHPunit Submit form with jquery-generation of values (for selects)

  15. 15

    Django: jQuery to trigger a form submit onchange of checkbox and retain the values on the reload

  16. 16

    Submit multiple form values with AngularFire

  17. 17

    Django Form submit manipulate values

  18. 18

    ReactJS Submit form with default values

  19. 19

    Pass values to $('form').submit(function ()

  20. 20

    How to get form values on submit?

  21. 21

    Submit a Form Using Jquery Ajax

  22. 22

    jQuery ajax Form Submit - how to?

  23. 23

    Ajax submit form with jquery not validating

  24. 24

    Using Ajax to submit form Jquery

  25. 25

    jquery ajax form submit is not working

  26. 26

    how to submit the form values using ajax call, without using submit button

  27. 27

    Add input into form with jquery and submit

  28. 28

    add calculated column to pandasdataframe depending on NULL values

  29. 29

    Postgres add column with initially calculated values

HotTag

Archive