I have a donation form and I've have created an editable donation total on my site. I need to copy the value from this box to the plugin donation total so when the form is submitted the plugin's value is used. I've used javascript to copy over the value and it is working:
var p = '£' + price;
$('#ffm-total').val(p);
var hiddenTotal = document.getElementById("give-final-total-wrap").getElementsByClassName("give-final-total-amount")[0];
hiddenTotal.innerHTML = p;
However, I also need the price to be editable. I've got the field:
<label class="give-label give-fl-label" for="ffm-total">Total</label>
<input class="textfield give-fl-input fill_inited filled" id="ffm-total" type="text" data-required="no" data-type="text" name="total" placeholder="Total" value="" data-value="£5199">
<p id="give-final-total-wrap" class="form-wrap ">
<span class="give-donation-total-label">
Donation Total: </span>
<span class="give-final-total-amount" data-total="18">
£18 </span>
</p>
and I tried to use:
var finalTotal = document.getElementById("#ffm-total");
var hiddenTotal = document.getElementById("give-final-total-wrap").getElementsByClassName("give-final-total-amount")[0];
hiddenTotal.innerHTML = finalTotal;
But it does not work. Although the value is editable it does not save the value in the rather in the 'data-value' so finalTotal.value
does give any value.
How do I get the value and use it to populate the hiddenTotal?
You can see the issue here: site with issue