3 Replies Latest reply on Jun 12, 2013 10:53 AM by Bernd Alheit

    Javascript Calculation

    RUDDOCKSJ

      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