IE doesn't offer "control arrays" though it
does provide an easy to use
implied element collection facility.
I think this is what you want:
Code:
<HTML>
<!-- saved from url=(0013)about:internet -->
<HEAD>
<SCRIPT language="VBScript">
Option Explicit
Sub cmdEchoBack_onclick()
Dim intCollIndex
Dim strEcho
With frmInput
For intCollIndex = 0 To .txtInput.length - 1
strEcho = strEcho & .txtInput(intCollIndex).value & vbNewLine
Next
End With
MsgBox strEcho
End Sub
Sub window_onload()
frmInput.txtInput(0).focus
End Sub
</SCRIPT>
</HEAD>
<BODY>
<FORM name="InputForm" id="frmInput">
<INPUT type="text" name="txtInput" id="txtInput" size="5">
<INPUT type="text" name="txtInput" id="txtInput" size="5">
<INPUT type="text" name="txtInput" id="txtInput" size="5">
<INPUT type="button" id="cmdEchoBack" value="Echo Back">
</FORM>
</BODY>
</HTML>
Note the use of the elements'
id attribute, which in general should be made the same as an element's
name in those cases where you really want to use name. Typically
name is simply a tag used to relay form elements sent back to the server. But there is no rule saying they have to have the same value (see the <FORM> tag in my example).
When you do not explicitly assign
id to an HTML element, IE will
try to coerce it to be the same as the name when one has been assigned, but this can fail. Therefore always explicitly assign
id to any HTML element you want to reference in script.
Now these are implied collections, implied by identical
ids on elements within a namespace scope (such as a given form). They are unlike arrays in at least two important ways:
They have indices from 1 to {collection}.length instead of starting at index = 0, and it isn't possible to create an implied collection with only one element.
To illustrate the latter case, if you had only one of those <INPUT id="txtInput"> elements you'd get a script error because you do not have a collection with one member, you just have an element.
To test this delete or comment two of them out of my example code above. The page will fail in the window_onload() event handler because there is no collection to index in such a case.