问题描述
我创建了一个 VBScript 函数 OnRefreshList(),单击刷新列表"按钮即可调用该函数.
I have created a VBScript function OnRefreshList() which is called on the click of a button "Refresh List".
Sub OnRefreshList ()
Initdatatable(false)
if ReadFilters() = false then
msgbox "It is not possible to refresh the whole orders list. Please enter more filters"
exit sub
end if
End Sub
刷新列表"按钮定义为
<td class="button cmd" valign="center" nowrap id="cmdRefresh" onclick="OnRefreshList()" title="Refresh the order list">Refresh List</td>
当我点击按钮时,这个功能工作正常.
This function is working fine when I am clicking on the button.
现在我想在按下键盘上的 Enter 键时调用这个函数.
Now I want to call this function when I press the Enter key from the key board.
为此,我尝试更改以下代码段,但对我不起作用.
For this I tried to change the following piece of code but it didnt worked for me.
<td class="button cmd" valign="center" nowrap id="cmdRefresh" onKeydown="vbscript: if (event.keyCode==13) then OnRefreshList()" onclick="OnRefreshList()" title="Refresh the order list">Refresh List</td>
如果有人有答案,请帮助我.
Please help me if anyone has an answer to it.
推荐答案
您的 onKeydown 事件中没有正确的 VBScript 语句.应该是:
Your onKeydown event does not have a correct VBScript statement in it. It should be:
onKeydown="vbscript: if event.keyCode=13 then OnRefreshList()"
注意单个 = 符号和缺少括号(它们不是强制性的).如果您更熟悉 javascript:您可以混合使用 VBScript 和 Javascript:
Notice the single = sign and the lack of parenthesis (they are not mandatory). If you are more comfortable with javascript: You can mix VBScript and Javascript:
onKeydown="javascript: if (event.keyCode==13) OnRefreshList(); //this will work too!"
这篇关于要在单击 Enter 键时调用 VBScript 函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!