iframe不是从下拉列表中写的

时间:2016-05-12 20:39:10

标签: javascript html iframe drop-down-menu multiple-instances

我已经浏览了网络上的答案,但找不到足够的特定内容来帮助 - 我发现的最后一件事是document.write函数,但也是"糟糕的做法"它是。我有一个下拉列表来更改谷歌地图上的标记,我想要相同的选择来拉入iframe表 - 应该很简单,但下面只会拉第一个iframe - 我不认为我的搜索字符串是正确 - 有人请修复我的代码,我花了几周时间!

      <label class="layer-wizard-search-label">
    Underground Line
    <select id="search-string_0" onchange="changeMap_0(this.value)" >
      <option value="--Select--">--Select--</option>
      <option value="Bakerloo">Bakerloo</option>
      <option value="Central">Central</option>
      <option value="Circle">Circle</option>
      </select>
  </label> 

    <script type = "text/javascript">
    var res = document.getElementById("search-string_0");

if (res="Bakerloo") {
document.write('<iframe  width="700" height="900" scrolling="yes" frameborder="no" src="https://www.google.com/fusiontables/embedviz?viz=GVIZ&amp;t=TABLE&amp;q=select+col1%2C+col5%2C+col6%2C+col9%2C+col10%2C+col7+from+1fsnkGRq7SphzxmrnbnYBP1MaAMnDQq-FvUb6TSCl&amp;containerId=googft-gviz-canvas"></iframe>');
} else if (res="Central"){
document.write('<iframe  width="700" height="900" scrolling="yes" frameborder="no" src="https://www.google.com/fusiontables/embedviz?viz=GVIZ&amp;t=TABLE&amp;q=select+col1%2C+col5%2C+col6%2C+col9%2C+col10%2C+col7+from+1IH846oqs0nUdFWW4td_OKUF4R3cQQriFzR2zLBx5&amp;containerId=googft-gviz-canvas"></iframe>');
} else {
document.write('<iframe  width="700" height="900" scrolling="yes" frameborder="no" src="https://www.google.com/fusiontables/embedviz?viz=GVIZ&amp;t=TABLE&amp;q=select+col1%2C+col5%2C+col6%2C+col9%2C+col10%2C+col7+from+1QwZaLH0v420t9Q9HXmc7pZjZU25_orToPhiMQBN-&amp;containerId=googft-gviz-canvas"></iframe>');
}

</script>

0 个答案:

没有答案