GomezAddamz
Technical User
Hey forum! I'm looking for a way to make a VBS script inside an HTA wait for input before continuing execution. Specifically, I have a dynamically populated list box from which the user will need to make a selection and then click a button before the script can continue. I know I can use the onClick event to start a process, but I do not know how to make a running process wait for an event before continuing (presuming it can even be done). This is, of course, part of a larger project, but the following code demonstrates the task-at-hand. Is there a way to send the selection back to the Window_onLoad sub, or am I barking up the wrong tree?
Code:
<html>
<head>
<title>Tester</title>
<HTA:APPLICATION
ID="TesterHTA"
APPLICATIONNAME="Tester"
SINGLEINSTANCE="yes"
>
</head>
<SCRIPT Language="VBScript">
Option Explicit
Dim FSO, objOption, testFile, testStr
Sub Window_onLoad
Set FSO = CreateObject("Scripting.FileSystemObject")
Set testFile = FSO.OpenTextFile("C:\test.txt",1)
Do Until testFile.AtEndOfStream
testStr = testFile.ReadLine
Set objOption = document.createElement("OPTION")
objOption.Text = testStr
objOption.value = objOption.Text
options.Add(objOption)
Loop
'Wait for user to click 'Submit' then run add'l code.
testFile.Close
End Sub
</SCRIPT>
<body>
<select id="options" size="4">
</select>
<br>
<button>Submit</button>
</body>
</html>