where子句使用IN查询问题

时间:2012-09-23 09:42:14

标签: javascript html google-maps-api-3 google-fusion-tables

我正在尝试启用复选框以打开和关闭ServiceType列中的“服务类型”。我在这里使用这个例子作为指导,但我没有在地图上显示任何点。我相信在为复选框生成where子句时会出现问题。我在这里使用这个例子:https://developers.google.com/fusiontables/docs/samples/in,但我完全感到困惑,并且没有丝毫知道他们的列名是什么,他们在商店的众多偏差中查询,我知道一些是数组和其他变量。

这是我的where子句(冒着让自己尴尬的风险):

function generateWhere() {
    var filter = [];
    var serviceTypes = document.getElementsByName('ServiceType');
    for (var i = 0, serviceType; serviceType1 = serviceTypes[i]; i++) {
      if (serviceType1.checked) {
        var serviceType2 = serviceType1.value.replace(/'/g, '\\\'');
        filter.push("'" + serviceType2 + "'");
      }
    }
    var where = '';
    if (filter.length) {
      where = "'ServiceType' IN (" + filter.join(',') + ')';
    }
    return where;
  }

1 个答案:

答案 0 :(得分:0)

自: https://groups.google.com/group/fusion-tables-users-group/browse_frm/thread/944b0dce33f18056#

您的“checkboxes.html”中有拼写错误(或错误) 这一行:

var serviceTypes = document.getElementsByName('ServiceType');

有:

var serviceTypes = document.getElementsByName('ServiceType1');

以及不存在的复选框的所有其他侦听器,会破坏事物。 当我将其更改回您发布的代码时,它对我有用:

http://www.geocodezip.com//Figueroa_Johnathan_checkboxes.html