Html 有条件地调用函数
我的VBScript应用程序中有一个子系统。它会在页面上填充一个表。单击一个搜索按钮,另一个按钮会使用Html 有条件地调用函数,html,vbscript,Html,Vbscript,我的VBScript应用程序中有一个子系统。它会在页面上填充一个表。单击一个搜索按钮,另一个按钮会使用window.location.reload()方法清除页面 我的问题是,当用户单击搜索按钮时,它会填充一个表,然后用户可以再次单击搜索按钮,该表将附加更多数据 我希望首先清除页面,然后填充表。 有迭代,所以我不能简单地调用Search(directory)Sub中的window.location.reload() 我的VBScript代码是: Sub Search(directory)
window.location.reload()
方法清除页面
我的问题是,当用户单击搜索按钮时,它会填充一个表,然后用户可以再次单击搜索按钮,该表将附加更多数据
我希望首先清除页面,然后填充表。
有迭代,所以我不能简单地调用Search(directory)
Sub中的window.location.reload()
我的VBScript代码是:
Sub Search(directory)
Dim flag
Dim found
Dim nodeinfo(4)
Dim ipath
On Error Resume Next
Set fldr = fso.GetFolder(FolderPath)
Set Fls = fldr.Files
For Each item In Fls
sFSpec = FSO.GetAbsolutePathName(item)
If LCase(FSO.GetExtensionName(item.Name)) = "xml" Then
objMSXML.async = True
'...
'More code here to generate table mytable ...
'...
End If
Next
Set fldrs = fldr.SubFolders
For Each item In fldrs
Search item.path
Next
End Sub
当前,如果表中有数据,我将禁用搜索按钮:
如果没有出现>0,则document.getElementById(“search\u btn”).disabled=True
编辑
要生成表,请执行以下操作:
Set mytable=document.createElement(“表”)
mytable.setAttribute“id”,“mytable”
mytable.setAttribute“对齐”、“居中”
设置thead=document.createElement(“thead”)
Set tr=document.createElement(“tr”)
Set th=document.createElement(“th”)
th.setAttribute“colSpan”、“5”
thead.appendChild tr
设置tr2=document.createElement(“tr”)
Set th1=document.createElement(“th”)
Set th2=document.createElement(“th”)
Set th3=document.createElement(“th”)
设置th4=document.createElement(“th”)
设置th5=document.createElement(“th”)
th1.innerText=“ABC”
th2.innerText=“DEF”
th3.innerText=“GHI”
th4.innerText=“JKL”
th5.innerText=“MNO”
tr2.1子项th1
tr2.2子类th2
tr2.th3
tr2.4
tr2.5
thead.appendChild tr2
mytable.appendChild thead
Set td1=document.createElement(“td”)
td1.innerText=nodeinfo(0)
tr3.1子项td1
有一个变量,比如no\u of_results
,它在返回结果时保存一个数字。基于该变量,我将禁用按钮。仅当按钮不存在时才创建
(和
):
Set mytable=document.getElementById(“mytable”)
如果mytable什么都不是
Set mytable=document.createElement(“表”)
'...
设置thead=document.createElement(“thead”)
'...
mytable.appendChild thead
如果结束
并将表内容放入
,以便在添加新搜索结果之前删除现有搜索结果:
mytable.getElementsByTagName(“tbody”)中每个tbody的
mytable.removeChild(t正文)
下一个
Set tbody=document.createElement(“tbody”)
'...
'创建行和单元格并将其附加到表体
'...
mytable.appendChild tbody
仅当它们不存在时才创建
(和
):
Set mytable=document.getElementById(“mytable”)
如果mytable什么都不是
Set mytable=document.createElement(“表”)
'...
设置thead=document.createElement(“thead”)
'...
mytable.appendChild thead
如果结束
并将表内容放入
,以便在添加新搜索结果之前删除现有搜索结果:
mytable.getElementsByTagName(“tbody”)中每个tbody的
mytable.removeChild(t正文)
下一个
Set tbody=document.createElement(“tbody”)
'...
'创建行和单元格并将其附加到表体
'...
mytable.appendChild tbody
我也遇到了类似的问题,但在我的例子中,我使用了Javascript,并以不同的方式处理了这种情况。在这种情况下,请尝试使用另一个函数,该函数将同时调用清除和加载函数
尝试此代码,单击一个按钮调用2个函数
<input name="Search" type="button" class = "buttongo aright" value="Search" OnClick="window.location.reload(); Search();">
我也遇到了类似的问题,但在我的例子中,我使用了Javascript,并以不同的方式处理了这种情况。在这种情况下,请尝试使用另一个函数,该函数将同时调用清除和加载函数 尝试此代码,单击一个按钮调用2个函数
<input name="Search" type="button" class = "buttongo aright" value="Search" OnClick="window.location.reload(); Search();">
调用两个函数检查时出现问题。。。调用这两个函数检查时出现问题。。。