我制作了与两个以上目的地相同的谷歌地图网页,以获得它们之间的方向。现在每当我点击使用网页中的锚标记添加更多目的地时,使用javascript我的表格行应该是可见的,其中一个目的地和标签的文本框将在那里。那么有人能说出使用javascript处理这种情况的过程吗?
您可以点击谷歌地图获取路线并添加更多目的地,以查看有关我的问题的更多信息。同样我想要。任何人都可以讲述。?
答案 0 :(得分:1)
如果我理解正确,这就是你需要的:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TableRowShow.Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
window.onload = function()
{
document.getElementById('addDestination').setAttribute('onclick', 'addDest();');
}
var i = 1; // position of next tr to be shown
function addDest()
{
var trs = document.getElementById('travelTable').getElementsByTagName('tr');
if (trs[i] != null)
trs[i++].style.display = "";
}
</script>
</head>
<body>
<form id="form1" runat="server">
<table id="travelTable">
<tr>
<td>
<asp:TextBox runat="server" />
</td>
</tr>
<tr style="display: none">
<td>
<asp:TextBox runat="server" />
</td>
</tr>
<tr style="display: none">
<td>
<asp:TextBox runat="server" />
</td>
</tr>
</table>
<asp:HyperLink runat="server" ID="addDestination"
ClientIDMode="Static" NavigateUrl="javascript:;" >
Add Destination
</asp:HyperLink>
</form>
</body>
</html>
代码应该是非常自我解释的,但是询问您是否有任何问题。 :)