问题
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
The "Refresh List" button is defined as
<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.
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.
回答1:
Your onKeydown event does not have a correct VBScript statement in it. It should be:
onKeydown="vbscript: if event.keyCode=13 then OnRefreshList()"
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!"
来源:https://stackoverflow.com/questions/11792428/to-call-a-vbscript-function-on-click-of-enter-key