Post by e***@netscape.netI have a dropdown box I want to use from an HTA and I want the contents
of that drops down to get pulled out of a simple text file. Can someone
post a vbscript example?
Here's one approach. Watch for word-wrap.
<< states.hta >>
<html>
<head>
<title>50states.hta</title>
<script type="text/vbscript">
Option Explicit
'*
'* Declare Constants
'*
Const cHTA = "states.hta"
Const cTXT = "states.txt"
'*
'* Delare Variables
'*
Dim arrOTF
Dim intOTF
Dim strOTF
Dim strSEL
'*
'* Read File
'*
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objOTF
Set objOTF = objFSO.OpenTextFile(cTXT,1)
strOTF = objOTF.ReadAll
arrOTF = Split(strOTF,vbCrLf)
Set objOTF = Nothing
Set objFSO = Nothing
'*
'* Each Record
'*
strSEL = "<select name='State'>"
strSEL = strSEL & "<option value=''>"
For intOTF = 0 To UBound(arrOTF)-1
strOTF = SPlit(arrOTF(intOTF),"=")
strSEL = strSEL & "<option value='" & strOTF(0) & "'>" & strOTF(1)
Next
strSEL = strSEL & "</select>"
</script>
</head>
<body onload="document.getElementById('States').innerHTML = strSEL">
<form>
<span id="States"></span>
<input type="button" value="Go"
onclick="javascript:alert(document.forms[0].State.value)">
</form>
</body>
</html>
<< states.txt >>
AK=Alaska
AL=Alabama
AR=Arkansas
AZ=Arizona
CA=California
CO=Colorado
CT=Connecticut
DC=District of Columbia
DE=Deleware
FL=Florida
GA=Georgia
HI=Hawaii
IA=Iowa
ID=Idaho
IL=Illinois
IN=Indiana
KS=Kansas
KY=Kentucky
LA=Louisiana
MA=Massachusetts
MD=Maryland
ME=Maine
MI=Michigan
MN=Minnesota
MO=Missouri
MS=Mississippi
MT=Montana
NC=North Carolina
ND=North Dakota
NE=Nebraska
NH=New Hampshire
NJ=New Jersey
NM=New Mexico
NV=Nevada
NY=New York
OH=Ohio
OK=Oklahoma
OR=Oregon
PA=Pennsylvania
RI=Rhode Island
SC=South Carolina
SD=South Dakota
TN=Tennessee
TX=Texas
UT=Utah
VA=Virginia
VT=Vermont
WA=Washington
WI=Wisconsin
WV=West Virginia
WY=Wyoming