Wednesday, April 25, 2012

jQuery input updates all IDs, rather than just the one required

The issue I'm having is fairly hard for me to explain, but I have replicated it in a jsFiddle http://jsfiddle.net/6ms4T/1/



What I am trying to achieve is by updating the 'Quantity' text box, I want to display the value elsewhere (the line below which I'll refer to as the 'Cost line').



Basically, updating the first input box (qty_item_1) is updating all the (quant_) IDs in the 'Cost line', rather than just the one related to that product.



function recalc(){

$("[id^=quant_]").text($("input[id^=qty_item_]").val());


etc...



Full code is here: http://jsfiddle.net/6ms4T/1/



Any help would be appreciated.





No comments:

Post a Comment