我相信这与您正在寻找的相似,这至少会给您一个可以构建的工作示例。该Window_OnLoad
子例程加载初始内容,然后新创建的内容包含一个按钮,单击该按钮会删除文本框/按钮并添加一个标记为 的新按钮Add Again?
。这个新按钮可以Window_OnLoad
再次调用子程序并重新加载原始内容。
<html>
<head>
<title>Dynamically Add Controls</title>
<HTA:APPLICATION
APPLICATIONNAME="Dynamically Add Controls"
ID="Dynamically_Add_Controls"
VERSION="1.0"/>
</head>
<script language="VBScript">
Sub Window_OnLoad
strHTML = "<tr><td>Source Path</td><td><input type="& Chr(34)& "text"&Chr(34)&">"&"</td><td><button type="&Chr(34)&"button"&Chr(34)& "onclick="&Chr(34)&"RemoveTextBox"&Chr(34)&">"&"Remove All?"&"</button></td></tr>"
DataArea.InnerHTML = strHTML
End Sub
Sub RemoveTextBox()
strHTML = "<td><button type="&Chr(34)&"button"&Chr(34)& "onclick="&Chr(34)&"Window_OnLoad"&Chr(34)&">"&"Add Again?"&"</button></td></tr>"
DataArea.InnerHTML = strHTML
End Sub
</script>
<body bgcolor="white">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><Div id="DataArea"></Div></td>
</tr>
</table>
</body>
</html>