我有一组复选框,选中后,应填充地图上的关联点。
这很好用:
var type_column = "FastFood";
var searchType = type_column + " IN (-1,";
if ( $("#divType1").is(':checked')) searchType += "1,";
if ( $("#divType2").is(':checked')) searchType += "2,";
if ( $("#divType3").is(':checked')) searchType += "3,";
if ( $("#divType4").is(':checked')) searchType += "4,";
whereClause += " AND " + searchType.slice(0, searchType.length - 1) + ")";
但这不会:
var type_column = "FastFood";
var searchType = type_column + " IN (-1,";
if ( $("#divType1").is(':checked')) searchType += "Arbys,";
if ( $("#divType2").is(':checked')) searchType += "Burgerking,";
if ( $("#divType3").is(':checked')) searchType += "Checkers,";
if ( $("#divType4").is(':checked')) searchType += "Dairyqueen,";
whereClause += " AND " + searchType.slice(0, searchType.length - 1) + ")";
将“Arbys”更改为“a”(等等)也不起作用,所以这与字符数无关。我还尝试在不包含逗号的字符串周围加上一组单引号。(遗憾的是,由于其他不相关的原因,仅使用数字并不是一种选择。)