我有一个使用VB代码的HTA提示符。我需要有两个下拉表上显示。由于某些原因,只有第二个下拉框显示"选择扇区"。当只有一个下拉菜单时,它工作得很好,但是当我添加第二个扇区时,它删除了第一个位置。我如何让两个下拉框都显示出来,就像:
选择当前位置:[DROPDOWN]
选择扇区:[DROPDOWN]
'AA Sites
Function startSTAGE3()
ON ERROR RESUME NEXT
LASTSTAGE = STAGE
bodystring = "<br>Select your current location: <SELECT SIZE='.5' NAME='Clocation' ONCHANGE='LOCCHANGED()'>"
bodystring = bodystring & "<option value='0'> </option>"
bodystring = bodystring & "<option value='MacDill AFB, FL, APO, AA'"
If locationindex = 1 Then bodystring = bodystring & " selected"
bodystring = bodystring & ">MacDill AFB, FL, APO, AA</option></SELECT>"
bodystring = "<br><br><br>Select your sector: <SELECT SIZE='.3' NAME='Csector' ONCHANGE='SECTORCHANGED()'>"
bodystring = bodystring & "<option value='0'> </option>"
bodystring = bodystring & "<option value='ES'"
If sectorindex = 1 Then bodystring = bodystring & " selected"
bodystring = bodystring & ">ES</option><option value='L&A'"
If sectorindex = 2 Then bodystring = bodystring & " selected"
bodystring = bodystring & ">L&A</option><option value='I&S'"
If sectorindex = 3 Then bodystring = bodystring & " selected"
bodystring = bodystring & ">I&S</option><option value='S2'"
If sectorindex = 4 Then bodystring = bodystring & " selected"
bodystring = bodystring & ">S2</option><option value='INC'"
If sectorindex = 5 Then bodystring = bodystring & " selected"
bodystring = bodystring & ">INC</option></SELECT>"
Function SECTORCHANGED()
ON ERROR RESUME NEXT
currentsector = Csector(Csector.selectedIndex).Value
sectorindex = Csector.selectedIndex
End Function
Function LOCCHANGED()
ON ERROR RESUME NEXT
currentlocation = Clocation(Clocation.selectedIndex).Value
locationindex = Clocation.selectedIndex
End Function
首先,您缺少第一个功能的End Function
。
第二个,而不是使用:
bodystring = bodystring & [...]
我建议:
bodystring += [...]
它更容易阅读,更少地聚集你的代码。
第三个,在这里使用之前覆盖bodystring
:
bodystring = bodystring & ">MacDill AFB, FL, APO, AA</option></SELECT>"
'The next commands overwrites bodystring before it is being used
bodystring = "<br><br><br>Select your sector: <SELECT SIZE='.3' NAME='Csector' ONCHANGE='SECTORCHANGED()'>"
bodystring = bodystring & "<option value='0'> </option>"
bodystring = bodystring & "<option value='ES'"
这可能是错误。
Edit1
我也建议使用
If [condition] then
'[stuff to do]
ElseIf [condition] then
'[stuff to do]
ElseIf [condition] then
'[stuff to do]
End If
代替你的行内If
s