nanharbison
asked on
jQuery change totals when many form textboxes are changed
I have about 25 textboxes where users enter how many of each component they want, and the text box which holds the total should change on the fly. Is there a way to check ALL of the textboxes for changes as they happen instead of writing out each one?
This is here:
http://www.cloudconnect.net/pricing-estimate
I thought this was working, but it is not, so I can't get to work either. It works in Firebug though, so I don't understand why it doesn't work on the page
function recalculateTotal() {
var count = $('#edit-submitted-users-d esktop-use rs').val() ;
count = parseFloat( count );
$('#edit-submitted-users-t otal-users -price').v al( count * p1 );
}
var fieldCount = $('#edit-submitted-users-d esktop-use rs');
fieldCount.change( recalculateTotal );
This is here:
http://www.cloudconnect.net/pricing-estimate
I thought this was working, but it is not, so I can't get to work either. It works in Firebug though, so I don't understand why it doesn't work on the page
function recalculateTotal() {
var count = $('#edit-submitted-users-d
count = parseFloat( count );
$('#edit-submitted-users-t
}
var fieldCount = $('#edit-submitted-users-d
fieldCount.change( recalculateTotal );
ASKER
Each textbox has a unique ID. How do I use a class or name?
Not on the page I looked at. There were at least two fields with the same ID and your code here obviously try to get at more than one field using one ID
Please have a look here
http://api.jquery.com/attribute-starts-with-selector/
Please have a look here
http://api.jquery.com/attribute-starts-with-selector/
ASKER
I have set up the form with with field sets, so those are the same for groups of textboxes, but the input textboxes are all different.
You need UNIQUE ids for all elements on a page
ASKER
Ugh, this is a Drupal site, and the module created these non-unique IDs, and I have no control over that. Is this why the javascript isn't working? it works perfectly when I run it in Firebug.
How come you have no control? Can't you edit the Drupal templates?
And what do you mean "it works in firebug" I used firebug to see you did not have unique ids
And what do you mean "it works in firebug" I used firebug to see you did not have unique ids
ASKER
Where do you look in firebug to see there are IDs that are not unique?
Apologies. Perhaps I saw
edit-submitted-users-deskt op-users-w rapper
and
edit-submitted-users-deskt op-users
edit-submitted-users-deskt
and
edit-submitted-users-deskt
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I did the code for this question on my own, by brute force. It isn't elegant at all, but it works. But I appreciate the time mplungjan put in to look at what I was doing.
Why not use class or name?