Attach the value to the element with the jQuery data method. Increment it on click, and then pass it to the newFieldset. Init method as the second param.
Voila! $(document). Ready(function() { //Add New Fieldset with Button var newFieldset = { init: function(groupIndex,current) { $newPerson= $("#Template"+groupIndex).
Clone(true); $newPerson. Children("p"). Children("label").
Each(function(i) { var $currentElem= $(this); $currentElem. Attr("for",$currentElem. Attr("for")+current); }); $newPerson.
Children("p"). Children("input"). Each(function(i) { var $currentElem= $(this); $currentElem.
Attr("name",$currentElem. Attr("name")+current); $currentElem. Attr("value",$currentElem.
Attr("value")+groupIndex+current); $currentElem. Attr("id",$currentElem. Attr("id")+current); }); $newPerson.
AppendTo("#mainField"+groupIndex); $newPerson. RemoveClass("hideElement"); }, currentID: null, obj: null }; $(". AddButton").
Click(function() { var groupIndex = $(this). Attr("title"); var current = $(this). Data('current'); $(this).
Data('current',++current); //newFieldset. Obj = this; //var fieldIndex = $(this). Attr("class"); newFieldset.
Init(groupIndex,current); }). Data('current',0); console. Log('r'); }) Happy jquery-ing to you sir.
Attach the value to the element with the jQuery data method. Increment it on click, and then pass it to the newFieldset. Init method as the second param.
Voila! $(document). Ready(function() { //Add New Fieldset with Button var newFieldset = { init: function(groupIndex,current) { $newPerson= $("#Template"+groupIndex).
Clone(true); $newPerson. Children("p"). Children("label").
Each(function(i) { var $currentElem= $(this); $currentElem. Attr("for",$currentElem. Attr("for")+current); }); $newPerson.
Children("p"). Children("input"). Each(function(i) { var $currentElem= $(this); $currentElem.
Attr("name",$currentElem. Attr("name")+current); $currentElem. Attr("value",$currentElem.
Attr("value")+groupIndex+current); $currentElem. Attr("id",$currentElem. Attr("id")+current); }); $newPerson.
AppendTo("#mainField"+groupIndex); $newPerson. RemoveClass("hideElement"); }, currentID: null, obj: null }; $(". AddButton").
Click(function() { var groupIndex = $(this). Attr("title"); var current = $(this). Data('current'); $(this).
Data('current',++current); //newFieldset. Obj = this; //var fieldIndex = $(this). Attr("class"); newFieldset.
Init(groupIndex,current); }). Data('current',0); console. Log('r'); }); Happy jquery-ing to you sir.
By the way, I tested this and it works just fine! ;) – KyleFarris Apr 15 '09 at 20:59 1 This was like a little bit of heaven. You really saved my life that day :) a little dramatic but I just wanted you to know how much I appreciated it – Kristen Zirkler Apr 24 '09 at 0:09 I really enjoy helping people.
The pleasure was/is all mine. ;) – KyleFarris Apr 24 '09 at 3:32.
If you don't make the current variable global it will should work. Try this: var newFieldset = { current: 0, init: function() { this. Current++; //rest of init code }, //all your other fieldset code here }; /* all other code */ EDIT: After re-reading the question, I would take a completely different approach to what you're trying to achieve.
The above code will still exhibit the same behavior for you. If the question hasn't been successfully answered I'll do a bigger writeup when I get home.
I would do something like that: ... var currents = {}; var newFieldset = { init: function(groupIndex) { var current = 0; if (currentsgroupIndex) { current = currentsgroupIndex; } ++current; currentsgroupIndex = current; ...
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.