In this example:
TestSub.vbs
a = "String"
TestSub a
Sub TestSub(a)
MsgBox "Test " & a
End Sub
The Sub function works just fine and displays the text "Test String" in the MsgBox
But in this example (embedded in a HTA)
TestSub2.VBS
Sub getdata
NameID = "name123"
' NameID = 123 ' (This works)
strHTML0 = strHTML0 & _
"<select>" & _
"<option onclick='UpdateSelect("& NameID &")' language='vbscript'>" & _
NameID & _
"</option>" & _
"</select>"
SelectBox.innerHTML = strHTML0
End sub
Sub UpdateSelect(NameID)
MsgBox "Test " & NameID
End sub
The NameID
is displayed in the selectbox, but when you call the sub it doesn't display in the messagebox, however, if you set NameID = 123
it displays the integer in the messagebox
Why can it only display integers and how can you make it display a string?
Posted whole .hta on pastebin
You are concatenating strings and must delimiter NameID value in this way:
"<option onclick='UpdateSelect("""& NameID &""")' language='vbscript'>" & _