View Full Version : Live Query change event not quite working in IE

08-12-2008, 08:11 PM
I have a form with a set of fields that need to be added to dynamically and have a total calculated from the values of each. I start out with one instance of each field, then add more with the click of a button. Changes to the values of the initial set of fields triggers the calculations, but not changes to the values of any added fields.

the fields:

<td><input type="text" name="day_rate[]" size="5" class="invoice_dayrate" /></td>
<td><input type="text" name="per_diem[]" size="5" /></td>
<td><input type="text" name="mileage[]" size="5" /></td>
<td><input type="text" name="lodging[]" size="5" /></td>

and the javascript:

$('input.invoice_dayrate').livequery('change', function() {
$('input.invoice_dayrate').each(function() {
var value = (this.value != '') ? parseFloat(this.value) : 0;
this.value = value.toFixed(2);
var subtotal = parseFloat($('#total_day_rate').val());
var subtotal = subtotal+value;

(javascript code for other fields has been omitted, they all work the same as the Day Rate field)

I have tried several different selectors: $('input.invoice_dayrate'), $('.invoice_dayrate'), $("input[name='day_rate[]']"), $(":text[name='day_rate[]']"). All with the same result.

Also the calculations are all done correctly when triggered. Its just that the calculations are only triggered when a change is made to a pre-existing field & not fields that have been added.

Btw this all works brilliantly in Firefox, just having trouble in IE (7 to be precise, haven't tried in IE6).