I am having problems with the following code: I have n numbers of select box, whose id are differentiated by the values that the variables ModName and level take:
container.innerHTML = '<form id="listToolForm_'+ModName+level+'"><select id="listToolSelect_'+ModName+level+'" onChange="selValue(this.selectedIndex,'+ModName'+, level)"><option value="0">---</option></select></form>';
The select box is then populated by values taken from a database (this part is not really relevant here). With each form, there is a hidden input with id= idArg'+ModName+'_lev'+level, that will store the index selected by the user, using onChange and the function selValue(x):
Here is the function selValue(index, ModName, level):
function selValue(index, ModName, level){
document.getElementById("idArg"+ModName+"_lev"+level).value = index;
}
I tried the script setting var ModName = "SL", and var level = 0. I get an error: 'SL is not defined'. Another test that worked is by replacing the function that fires up onChange:
onChange="selValue(this.selectedIndex)"
and
function selValue(index){
var level = 0;
var ModName = "SL";
document.getElementById("idArg"+ModName+"_lev"+level).value = index;
}
So if the function fired up onChange has one argument, the code works, but does not when using several arguments. I suspect it's because of the line:
onChange = "selValue(this.selectedIndex,'+ModName'+, level)"
I tried:
onChange="'+window["selValue"](this.selectedIndex, ModName, level)+'"
without success.