jquery - Loop on ID and each function -
I use JQUERY for each dynamically 12 text box values with a "txt" class with this code I do:
& lt; Script & gt; $ (Document) .ready (function () {// repeat through each text box and adding the keypad / handler, which turns on Yoga Event $ (".txt"). $ (This) .keyup (function () {CalculateSum ();});});}); Function calculation () {var sum = 0; // Repeat through each text box and add values to $ (".txt"). Each (function () {// only add if the value is the number (if! (Nan (this.value)) and amp; this.value length! = 0) {sum + = parseFloat (this.value) ;}}}. $ ("# Yoga") HTML (zodiac); I use dynamically using only 3 text box values I want to create 4 subtotals calculated. I added 4 different IDs for each of my forms, for dynamically subscribing sub-totals for the current ID, I How can I use the given function? Spence ID is the result of which the name "ID_SUM" is kept (the text box should be dynamic according to the ID value modified) ?? Thanks a lot. P>
I found a solution ... ID is unique, so it does not work. Used:
& lt; script & gt; $ (Document) .ready (function () {//. Repeat Adyam and connects adding-Key / handler that will turn on the yoga event $ ( ".txt"). Each (function () {$ (this) .keyup (function () {CalculateSum ($ (this) .attr ("name"));});});}); Function Count Shu (Group) {var sum = 0; Var subscript = 0 // Repeat through each text box and add values to $ (".txt"). Every (function () {// should be added only if the value is the number (! IsNaN (this.value)) and this.value.length! = 0) {sum + = parseFloat (this.value);} }); // Toofix () method will run the last amount in 2 decimal places: $ ("# sum"). Html (sum.toFixed (2)) $ ("# sum"). Html (sum); $ ('Input [name =' '+ group +' "] '). Each (function () {// only adds if the value is the number (! IsNaN (this.value) & amp; amp; ; This.value. Length! = 0) {subtotal + = parseFloat (this.value);}}); // tofix () method The last amount will be played in 2 decimal places: $ ("# sum"). Html (Sum.toFixed (2)) $ ("#" + group + "_SUM"). Html (sub-total);} < / Html>
Comments
Post a Comment