- Where Developers Learn, Share, & Build Careers
I am looping through a set of 16 IDs and assigning a eventListener to each I am doing I want to send a number to my php file (1 for first ID, 2 for others, etc, etc.), but it seems that i is more dynamic than I want. Each ID sends 17 . Get an internal element by klasses.forEach (function (klass) {var svgElement = svgDoc.getElementById (klass); // id svgElement .addEventListener ("mouseup", function () {$ $ ("#modLSpan"); .ax ((type: "POST", url: "buildService.php", data: {"service": i}}). (Function (msg) {alert (Layerre [i] ) .HTML (msg); $ ("# modmodal"). Modal ();})}}); i ++;}); How can I set each to a specific number? I have also tried: var lameArray = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, 16]; ... data: {"service": lameArray [i]} Code> I ? The problem is that i is a global variable, or a variable outside circle for , so when the mouseup event begins The element in the value i ...