Variable "x" doesn't exist in that code because its being executed in event handler, not inside that loop, so you'll need a different approach.
I'd go with a big eval() like this:
Code:
for(var x=0; x<10; x++)
{
eval('var fn = function(evt){
dojo.xhrPost({
url: "drop2.php",
handleAs: "json",
postData: "data=" + $(this).val(),
preventCache: true,
load: function(json) {
$m' + x + ' = [];
for (var i = 1; i < 10; i++) {
$m' + x + '.push(parseFloat(json[i]["valor" + i]));
}
dojo.addOnLoad(refreshChar' + x + ');
}
});
};');
dojo.query("body").delegate("#input" + x + " > select.estatistica", "onchange", fn);
}
It takes that function's code, replaces number with value of x and assigns it to variable fn, then fn is being assigned as event handler to correct item. There might be typos in that code or it might not work at all.
Bookmarks