Recent posts by m4rtini

Subscribe to Recent posts by m4rtini 2 posts found

Nov 7, 2007
m4rtini 2 posts

Topic: Script development / dynamic eventlistener problem

sel.addEventListener("click",function (){ fillSelect(id)}, true);

this statement is in a loop where the event is added last, the problem is that the variable 'id' will change when the loop repeats, and i end up with all the events having the same id passed to fillSelect

is there any way that i could fix this?

 
Oct 14, 2007
m4rtini 2 posts

Topic: Script development / settimeout problem

i read pieces of another post http://userscripts.org/forums/1/topics/567 and ended up with this code:

function repeat(i, ant, count)
{

//define som variables etc..

if (i<cord>
{

if (ant<=total)
{
var myTimer = count;


var temp = cord[i].split(",");
var xcord = temp[0];
var ycord = temp[1];
var url = "http://some.url";
var postvar = 'some post data';
post(url, postvar);
window.setTimeout(function(){ant++; count++; repeat(ant, i, count)},myTimer);
alert("test4");
}else{

window.setTimeout(function(){i++; ant=1; count++; repeat(ant, i, count)},1);}
}

}

var button = document.getElementById('mybutton');
button.addEventListener("click", repeat, true);

i'm not getting any errors in the ff error window. but the problem seams to be that the timeout doesent execute