I am integrating a jQuery pricing calculator with a shopping cart. I want to update a hidden field when the .text(); value of an element is changed.
This is the field that I am trying to update:
<input id="firewall-price" type="hidden" name="price" value="" />
from here:
<div class="orderRow server firewall" contain="firewall" id="">
<div class="quantity"><span></span></div>
<div class="name">Firewall</div>
<div class="price orderPrice">$0</div>
</div>
using this jQuery:
$(document).ready(function(){
var price = $( ".firewall .price" ).text().substr(1);
$(price).change(function(){
$("input[name=firewall-price]").val(price);
});
});
I can't get the value of the input[name=firewall-price] to update when the number is changed. I know it is a little strange doing it this way but I want to just take the final values from the calculator and send them to the shopping cart.
Here is a link to the dev site: http://mindcentric.thelabelcreative.com/pricing_calculator/
$(price)is a selector that finds an element whose tag name is the text content of the.pricefield. You can't bind an event handler to a string itself, only to DOM elements.