Reputation: 3697
I have a span (#sum) which changes dynamically, adding up the values of selected options in a form. I want to append the text from this to the value of a hidden input field so I can email the figure.
So my html is
<span id="sum">£0.00</span>
and my hidden field is
<input type="hidden" name="total" value="" />
But using jQuery that needs to read
<input type="hidden" name="total" value="[WHATEVER THE NUMBER IN THE SUM SPAN IS]" />
Here is the jQuery I have so far:
var total = $('#sum').html();
$('#total').val(total);
Upvotes: 0
Views: 2600
Reputation: 39248
<input name="total" type="hidden" id="total" value="" />
You are referring to it by id. Add the id
Upvotes: 3