ajax - jQuery math two float numbers -


i try math 2 float number , add them ajax query. didnt work. here code:

    // padejpremium_x 225.00     var amount = $("#padejpremium_2").val() / 100) * 2; // (225.00 / 100) * 2 = 4.5     var data = {         dueamount0: $("#padejpremium_1").val() + 10.00,         dueamount1: $("#padejpremium_2").val() + amount,         dueamount2: $("#padejpremium_3").val() + amount,         dueamount3: $("#padejpremium_4").val() + amount, 

i glad if give idea. in advance.

you have missing ( in first line. check below code:

var amount = ($("#padejpremium_2").val() / 100) * 2; // (225.00 / 100) * 2 = 4.5 var data = {     dueamount0: $("#padejpremium_1").val() + 10.00,     dueamount1: $("#padejpremium_2").val() + amount,     dueamount2: $("#padejpremium_3").val() + amount     }     console.log(data); 

check demo here:

jsfiddle (check in console)


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -