jQuery我不能让两个zip列表显示在地图上

时间:2015-07-23 23:36:58

标签: javascript php jquery html

这是我的代码:

jQuery(document).ready(function() {

  var nhZips="77014, 77015, 77032, 77060, 77064, 77067, 77065, 77066, 77068, 77069, 77070, 77073, 77090, 77301, 77302, 77304, 77338, 77354, 77355, 77362, 77373, 77375, 77377, 77379, 77380, 77381, 77382, 77384, 77385, 77386, 77388, 77389";

  var nehZips="77032, 77044, 77336, 77339, 77345, 77346, 77347, 77357, 77365, 77396";

  var acworthZips="30101, 30102"

  $("#nhZips").html(nhZips);
  $("#acworthZips").html(acworthZips)

  var searchArr = [[nhZips+", "+nehZips,"north-houston"]];

  $( "#zipform" ).submit(function() {
    var inArray=false
    var searchVal=$("input.search-box").val();
    for (var i=0;i<searchArr.length;i++){
        searchStr=", "+searchArr[i][0]+",";
        goToLoc=searchArr[i][1];
        if(searchStr.indexOf(", "+searchVal+",")>=0){
            $( "a#pric-loc-btn" ).attr("href", "http://hlmaids.com/get-a-price/get-a-price/"+goToLoc);
            inArray=true;
            break;
        }
    }
    if(inArray){
        $( "#search-answer" ).show( 0 );
        $( "#search-answer-fail" ).hide( 0 );
        var value = $("input.search-box").val();
        $( "span#zip-success" ).text( value );
    }
    else {
        $( "#search-answer-fail" ).show( 0 );
        $( "#search-answer" ).hide( 0 );
        var value = $("input.search-box").val();
        $( "span#zip-fail" ).text( value );
    };
     return false;
  });
});

http://hlmaids.com/get-a-price/

是它正在显示的页面。所以现在我只能得到nhZips来表明我们在该地区服务。

我尝试更改此代码

var searchArr = [[nhZips+", "+nehZips,"north-houston"]];

var searchArr = [[acworthZips+", "acworth"]&&[nhZips+", "+nehZips,"north-houston"]];

然后它只显示一个而不是另一个拉链列表。

1 个答案:

答案 0 :(得分:0)

var searchArr = [[acworthZips+", "acworth"]&&[nhZips+", "+nehZips,"north-houston"]];

需要更改为

var searchArr = [[acworthZips+", "acworth"],[nhZips+", "+nehZips,"north-houston"]];