However, I need to have a different onmouseover for each div (I'm going to be using an ajax call inside each onmouseover that pulls a different url depending on the div that you have pointed at)
Here is the snippet of code that I used to add the onmouseover attribute to each div. This section of code is inside a larger loop, so the "div" variable is a unique div on each iteration of the loop:
div.onmouseover = function() {
var x1 = (str[0]+3)/9;
var y1 = (str[1]+3)/9;
var url = "http://space.mygamehandle.com/scripts/star_name.php?x=" + x1 + "&y=" + y1;
new Ajax(url, {
method: 'get',
update: $('label_texter'),
onComplete: function() {
alert(url);
}
}).request();
}
The str array is a collection of x and y coordinates that the script at star_name.php uses to determine what information needs to be displayed inside the div "label_texter" in the ajax call. If you are not familiar with the mootools framework, you can ignore most of the code inside the function.
The real problem is that for some reason, all the div's created end up with the exact same thing within the url variable. Even though the str[0] and str[1] variables are changed on each iteration of the loop.
In fact, it seems as though they all end up with the last str array values in the loop.
I'm sure it has something to do with the function or something. not sure where to start fixing it.

Start a new topic
Add Reply


MultiQuote

| 


