user4317867
user4317867

Reputation: 2448

HTA/VbScript - If statement from Dropdown list choice

In my HTA using vbscript I am trying to read a choice from a DropDown list that will run specific code for each choice.

I've been poking around looking for some method to use the value of a DropDown list to run a specific VBSCRIPT subroutine but have not found anything helpful in my search. The code below does work however it only displays a message box with the choice listed. Any pointers would be extremely appreciated!!

<select name="BuildStepChoice" size="1">
 <option selected="selected" value=" "></option>
 <option value="1">1</option>
 <option value="2">2</option>
</select> &nbsp;

And the VBSCRIPT

Sub Copychecklist()
Dim VMBuildStep
VMBuildStep = document.getElementById("BuildStepChoice").Value
 If VMBuildStep = 1 Then MsgBox "Picked #1" Else
 If VMBuildStep = 2 Then MsgBox "Picked #2" End If
End Sub

Upvotes: 0

Views: 1434

Answers (1)

user4317867
user4317867

Reputation: 2448

Not sure where I picked this up, but this is what I ended up with.

Sub Copychecklist()
 Dim VMBuildStep
 VMBuildStep = document.getElementById("BuildStepChoice").Value
  If (IsNumeric(VMBuildStep)) Then
  VMBuildStep = Int(VMBuildStep)
  If (VMBuildStep >= 1 And VMBuildStep <= 17) Then CreateFile(VMBuildStep)
 End If            
End Sub

Upvotes: 0

Related Questions