Guest User

Untitled

a guest
Mar 23rd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. ## app.js ##
  2. $(document).ready(calculate);
  3. $(document).on("keyup", calculate);
  4. function calculate() {
  5. var sum = 0;
  6. ## php ##
  7. var value1 = $("#a_price").val();
  8. var value2 = $("#otherElemenet").val();
  9. $(".o-money__answer").each(function(){
  10. sum += parseFloat($(this).val()) * parseFloat(monetary_factor.replace(",", ".")) * parseFloat($(this).parent().find('input[type=hidden]').val());
  11. });
  12. $("#o-money__totalsum").html(sum.toFixed(2));
  13. }
  14. <form class="o-money__form" id="<?php echo $counter; ?>" method="post" action="#">
  15. <?php $rows = get_field('pengar'); ?>
  16. <?php if ($rows): ?>
  17. <?php foreach($rows as $row): ?>
  18. <div class="o-money__positionInput">
  19. <div class="right50">
  20. <label class="label labelInput">Antal <?php echo $row['typ_av_enhet']; ?></label>
  21. </div>
  22. <input type="text" value="" class="o-money__answer">
  23. <input type="hidden" value="<?php echo $row['a_price'];?>">
  24. </div>
  25.  
  26. <?php endforeach; ?>
  27. <label id="o-money__totalsum"> 0</label>
  28. </form>
  29. <!-- <?php if(have_rows('pengar')):while(have_rows('pengar')) : the_row();
  30. $a_price = get_sub_field('a_price');
  31. $monetary_factor = get_field('monetary_factor', 'option');
  32. ?> -->
  33. <?php break; endwhile; endif; ?>
  34. <?php endif; ?>
  35. </form>
  36. </div>
  37. </div>
Add Comment
Please, Sign In to add comment