In Firebug when I rollover the SelectList variable it certainly looks like an array.
if (GroupList != "") {
$('select[name^=DDLColumns1] option').each(function(){
if ($(this).val() != "-1") {
var ItemsArray = $(this).val().split('|');
var DataTypes = ItemsArray[1];
var TestItem = "[" + ItemsArray[0] + "]";
PROBLEM IS HERE---> if (jQuery.inArray(TestItem, SelectList) != -1) {
开发者_Python百科 if(DataTypes == 104)
NewSelectList += " SUM(CAST(" + ItemsArray[0] + " AS INT)) as " + ItemsArray[0] + ",";
else
NewSelectList += " max(" + ItemsArray[0] + ") as " + ItemsArray[0] + ",";
}
}
});
if(NewSelectList.length > 0) {
NewSelectList = NewSelectList.substring(0, NewSelectList.length - 1);
SelectList = NewSelectList;
}
}//end of if GroupList is not empty
What about cleaning up that mess first? Your errors should get clear if you do it.
if (GroupList != "") {
$('select[name^=DDLColumns1] option').each(function() {
if ($(this).val() != "-1") {
var ItemsArray = $(this).val().split('|');
var DataTypes = ItemsArray[1];
var TestItem = "[" + ItemsArray[0] + "]";
if (jQuery.inArray(TestItem, SelectList) != -1) {
if(DataTypes == 104)
NewSelectList += " SUM(CAST(" + ItemsArray[0] + " AS INT)) as " + ItemsArray[0] + ",";
else // <--- why all of a sudden no {}?
NewSelectList += " max(" + ItemsArray[0] + ") as " + ItemsArray[0] + ",";
}
//} //<--- why is commented out? it breaks everything
} //<-- this closes the callback
}); //<-- broken close of the if
if(NewSelectList.length > 0) {
NewSelectList = NewSelectList.substring(0, NewSelectList.length - 1);
SelectList = NewSelectList;
}
} // <---- what is this for? yeah it's broken
PS: Normally variables start with a lowercase letter and classes start with an uppercase one
if($.isArray( SelectList ) == false)
SelectList = SelectList.split(',');
精彩评论