嗨,我正在尝试使用/添加在本网站http://www.freemaptools.com/how-far-is-it-between.htm上找到的免费地图工具到我当前的网站上,这些网站是我们员工经常使用的工具列表,我打算嵌入它,但是它没有似乎没有这种功能,我问你们是否可以为我提供我想完成的任务的替代方法。在执行此“工具箱”时,我也愿意制作自己的地图工具来测量国家之间的距离。如果可以的话请指导我。谢谢。这是到目前为止我得到的

码:

<form name="inp">
<table align="center" width="95%" border="0">
<tbody><tr>
    <td width="30"></td>
    <td align="right">City, Country</td>
    <td></td>
    <td>City, Country</td>
    <td width="30"></td>
</tr>

<tr>
<td width="30"></td>
 <td width="269" align="right">From
<input name="pointa" type="text" value="" size="22" onkeypress="autocompletea(this.value, event)"></td>
<td width="34"><div align="center">to</div></td>
<td width="271"><input name="pointb" type="text" value="" size="22" onkeypress="autocompleteb(this.value, event)"> <input name="show" type="button" value="Show" onclick="findaandb(document.forms['inp']['pointa'].value,document.forms['inp']['pointb'].value);">
  <label></label></td>
<td width="30"></td>
</tr>
<tr>
<td colspan="2">
<div id="autocompletediva" class="autocomp" style="display: block; visibility: hidden; height: 0px; width: 0px;"></div>
</td>
<td></td>
<td colspan="2">
<div id="autocompletedivb" class="autocomp" style="display: block; visibility: hidden; height: 0px; width: 0px;"></div></td>
</tr>
<tr>
<td colspan="5"><div id="msg" class="msg">&nbsp;</div></td>
</tr>

<tr>
<td colspan="5" align="center"> Measure in :
<input name="dist" type="radio" onclick="toggleUnits('MILES');" checked="CHECKED">
<font face="verdana, geneva, helvetica" size="2">miles<input type="radio" name="dist" onclick="toggleUnits('KMS');">
 km</font>
</td>
</tr>

<tr><td colspan="5" align="center"><strong>Distance as the Crow Flies </strong> :
      <input style="display: inline;" id="distance" type="text" size="10" value="0.000" readonly="true">
      <img src="" alt="As the crow Flies"> </td>
</tr>
<tr>
<td colspan="5" align="center"><strong>Distance by Land Transport</strong> :
      <input style="display: inline;" id="transport" type="text" size="10" value="0.000" readonly="true">
      <img src="" alt="Land Transport">
</td>
</tr>
</tbody></table>
</form>

最佳答案

我认为您缺少javascript部分

onkeypress="autocompletea(this.value, event)"

onclick="toggleUnits('KMS');"

onclick="toggleUnits('MILES');"


这些都是javascript函数调用,但是您发布的只是HTML部分。快速查看您发布的网页,我认为至少您缺少以下JS文件。
http://www.freemaptools.com/script/how-far-is-it-between.js

尽管我认为如果您缺少此功能,可能是因为这是您第一次创建网页,HTML只是布局,而JavaScript使您可以“动态化” HTML(嗯,我认为很多人会不同意,但是有点。

我建议您看一下JavaScript教程,我现在不打算保留任何优点,但是请确保,如果您是google的用户,那么周围会发现很多不错的教程。

希望有所帮助

10-05 19:45
查看更多