Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-12-2008, 07:11 PM   PM User | #1
agentfloyd
New to the CF scene

 
Join Date: Aug 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
agentfloyd is an unknown quantity at this point
Live Query change event not quite working in IE

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:
Code:
<tr>
	<td></td>
	<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>
	<td></td>
	<td></td>
</tr>
and the javascript:
Code:
$('input.invoice_dayrate').livequery('change', function() {
	$('#total_day_rate').val(0);
	$('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;
		$('#total_day_rate').val(subtotal.toFixed(2));
	});
	update_total();
});
(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).
agentfloyd is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:30 AM.


Advertisement
Log in to turn off these ads.