Quantcast
Channel: Adobe Community : Unanswered Discussions - Acrobat
Viewing all articles
Browse latest Browse all 73766

Javascript Calculation

$
0
0

I'm pretty sure I'm being stupid but why isn't this working!?


form.find( '.per_time' ).on( 'change', function() {

                                  var price = parseInt( form.find( '.section-price' ).attr('data-price'), 10 ) ;

                                  var multiplier = parseInt( $( this ).val(), 10 );

                                  var newprice = (price / 7) * multiplier;

                                  form.find( '.section-price .price' ).html( newprice )

})

 

 

It's this line I'm concerned about:

 

 

var newprice = (price / 7) * multiplier;

 

 

The calculation is not dividing by 7, it only calculates `price * multiplier`?

 

 

This code also seems to be dictating what happens but I'm pretty sure it's jsut a shorter version of the above.

 

 

n.find(".per_time").on("change",function(){var t=parseInt(n.find(".section-price").attr("data-price"),10);r=parseInt (e(this).val(),10);i=(t/7)*r;n.find(".section-price .price").html(i);});

 

 

Thanks for all your help in advance. Here is an example of the input.

 

 

(595 / 7) * 10


Viewing all articles
Browse latest Browse all 73766

Trending Articles