HTA Scripts‎ > ‎

What Type is this Control?

Here I will try to explain the differences types of Controls that you can find in a HTA.
We have several controls in HTML that we can add to our HTA:
We can get or set the Value of each of them by using simple functions, demonstrated in each Control subpage link.

Control Types

All HTML Controls have a control type, some are input controls that are designed to give the user an interface for data input and some are designed to let the User choose between Options.
This is a list of the common Controls and there Types:
  • Text Field: HTMLInputElement
  • Password Field: HTMLInputElement
  • Button: HTMLInputElement
  • CheckBox: HTMLInputElement  
  • ListBox: HTMLSelectElement
  • ComboBox: HTMLSelectElement
  • RadioButton: DispHTMLElementCollection
  • Text Area: HTMLTextAreaElement
In Order to check for a Control Type you can simply Define it a Name Property and Echo using the TypeName Function, this will echo you the Control Type Name.
For Example you can insert an Image
<img src="NiceImage.gif" alt="Nice Image" />
Adding it a Name Property
<img name=myImg src="NiceImage.gif" alt="Nice Image" />
And then Echo its Type
MsgBox TypeName(myIMG)
And there you have it, You will get the Image Type: HTMLImg

This is the Complete Sample for Getting an Image Type Name
<html>
<head>
<title>My HTML application</title>
<HTA:APPLICATION
 APPLICATIONNAME="My HTML application"
 ID="MyHTMLapplication"
 VERSION="1.0"/>
</head>
<script language="VBScript">
Sub Window_OnLoad
 MsgBox TypeName(myIMG)
End Sub
</script>
<body bgcolor="white">
<img name=myImg src="angry.gif" alt="Angry face" />
</body>
</html>

HTMLInputElement

This Control Type is Used for Getting the User Input.
Controls that are part of the HTMLInputElement Type are:
Text Fields, Buttons, Check Boxes, Password Fields and Radio Buttons (Only when there is a Single Radio Button in the Group).
A Control with this Type has the basic functions of input.
For example a text box or a password field has the Text Value Property, The HTMLInputElement refers to that Property - Has a Value or Not.
This way the Element knows to Return us the Value.
Another Example is the Radio Button. Radio Buttons have Option Groups, if a Radio button has only one Element in its group the Element is no longer Witch Option is Selected but Is the Option Selected Yes/No.
That makes a Radio Button with Only One Option to a HTMLInputElement Rather than a DispHTMLElementCollection.

HTMLSelectElement

This Control Type is Used to Distinguish between the Selected Options.
Control that are part of the HTMLSelectElement Type are:
ComboBox and ListBox.
I these controls you can select one (or More) Options, Normally it has one Selection, Thats is why it has the Type Control of HTMLSelectElement.
This Control has the Property value of Selected, This let you know if an Option item is Selected or not.
This Can be Used in a Multi-Valued Selections as well, like in a Multi Selection ListBox.

DispHTMLElementCollection

One of the Controls that are part of this Type is the RadioButton.
The RadioButton has a Group of Options, all of them are Visible all the Time.
That is why the Control is Called a DispHTMLElementCollection, You can Choose an Option from a Visible Collection of Options.
This Control has the Checked Property to help us know witch Option is Selected (or Checked).