servus ichBinEinAlien,
var key = 'dynVar' + i;
var val = '=document.createElement("a")';
eval(key + val);
var ce = eval(key)
Warum benutzt du so ein wirres Konstrukt statt eines Arrays? Bzw... im Prinzip brauchst du nur eine einzige Variable, warum machst du das so?
Außerdem: eval is evil
document.body.appendChild(ce).setAttribute('href', '#')
document.body.appendChild(ce).onclick = function() {
selection(sId[i]);
document.getElementsByName('filter')[0].click();
};
document.body.appendChild(ce).innerHTML = sId[i];
Weißt du, was http://de.selfhtml.org/javascript/objekte/node.htm#append_child@title=appendChild macht?
Versuchs mal so:
for(var i = 0; i < sId.length; i++){
var link = document.createElement('a');
link.href = '#';
link.innerHTML = sId[i];
link.onclick = function(){
// etc
}
document.body.appendChild(link);
}
henf
--
"Sir, we are surrounded!" - "Excellent, we can attack in any direction!"
"Sir, we are surrounded!" - "Excellent, we can attack in any direction!"