【问题标题】:where clause using IN query issue使用 IN 查询问题的 where 子句
【发布时间】:2023-04-03 13:55:01
【问题描述】:

我正在尝试实现复选框以打开和关闭 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;
  }

【问题讨论】:

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


【解决方案1】:

来自: 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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-30
    • 1970-01-01
    相关资源
    最近更新 更多