Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## app.js ##
- $(document).ready(calculate);
- $(document).on("keyup", calculate);
- function calculate() {
- var sum = 0;
- ## php ##
- var value1 = $("#a_price").val();
- var value2 = $("#otherElemenet").val();
- $(".o-money__answer").each(function(){
- sum += parseFloat($(this).val()) * parseFloat(monetary_factor.replace(",", ".")) * parseFloat($(this).parent().find('input[type=hidden]').val());
- });
- $("#o-money__totalsum").html(sum.toFixed(2));
- }
- <form class="o-money__form" id="<?php echo $counter; ?>" method="post" action="#">
- <?php $rows = get_field('pengar'); ?>
- <?php if ($rows): ?>
- <?php foreach($rows as $row): ?>
- <div class="o-money__positionInput">
- <div class="right50">
- <label class="label labelInput">Antal <?php echo $row['typ_av_enhet']; ?></label>
- </div>
- <input type="text" value="" class="o-money__answer">
- <input type="hidden" value="<?php echo $row['a_price'];?>">
- </div>
- <?php endforeach; ?>
- <label id="o-money__totalsum"> 0</label>
- </form>
- <!-- <?php if(have_rows('pengar')):while(have_rows('pengar')) : the_row();
- $a_price = get_sub_field('a_price');
- $monetary_factor = get_field('monetary_factor', 'option');
- ?> -->
- <?php break; endwhile; endif; ?>
- <?php endif; ?>
- </form>
- </div>
- </div>
Add Comment
Please, Sign In to add comment