ginolard
-
Total Posts
:
1347
- Scores: 23
-
Reward points
:
0
- Joined: 8/11/2005
-
Status: offline
|
A basic HTA template
Thursday, December 07, 2006 12:52 AM
( permalink)
I thought this might prove useful to the HTA virigins amongst you. It's a very basic HTA template that demonstrates some of the most common DHTML objects
<html>
<title>HTA template</title>
<head>
<HTA:APPLICATION
APPLICATIONNAME="HTA Template"
SCROLL="yes"
SINGLEINSTANCE="yes"
WINDOWSTATE="normal"
>
</head>
<style>
BODY
{
background-color: buttonface;
Font: arial,sans-serif
margin-top: 10px;`
margin-left: 20px;
margin-right: 20px;
margin-bottom: 5px;
}
.button
{
width: 91px;
height: 25px;
font-family: arial,sans-serif;
font-size: 8pt;
}
td
{
font-family: arial,sans-serif;
font-size: 10pt;
}
#scroll
{
height:100%;
overflow:auto;
}
SELECT.FixedWidth
{
width: 17em; /* maybe use px for pixels or pt for points here */
}
</style>
<script language="VBScript">
Sub Window_OnLoad
'Code to run when HTA loads goes here
MsgBox "Hello and welcome to my HTA"
'Here we add values to the Combobox called ComboBox1
Set objOption = Document.createElement("OPTION")
objOption.Text = "FuzzyWuzzyBunny"
objOption.Value ="FuzzyWuzzyBunny"
ComboBox1.Add(objOption)
Set objOption = Document.createElement("OPTION")
objOption.Text = "FuzzyWuzzyKitten"
objOption.Value ="FuzzyWuzzyKitten"
ComboBox1.Add(objOption)
TextArea.InnerText="This is a text area"
End Sub
Sub ButtonClick
MsgBox "You clicked a button!"
End Sub
Sub ChangeSpanArea
If Not SpanArea.InnerText = "Text has been changed. Click the button again to change it back" Then
SpanArea.InnerText="Text has been changed. Click the button again to change it back"
Else
SpanArea.InnerText="Click the ChangeSpanArea button to change this text"
End If
End Sub
Sub ComboBoxChange
MsgBox "The Value of the Combobox is currently " & ComboBox1.Value
End Sub
Sub CheckBoxChange
If CheckBox.Checked Then
MsgBox "CheckBox is checked"
Else
MsgBox "CheckBox is not checked"
End If
End Sub
Sub CheckRadioButtons
End Sub
</script>
<body>
<input class="button" TYPE=BUTTON value="TestButton" name="btnTestButton" onClick="ButtonClick">
<input class="button" TYPE=BUTTON value="ChangeSpanArea" name="btnChangeSpanArea" onClick="ChangeSpanArea">
<br>
<br>
<select size="1" class="FixedWidth" name="ComboBox1" onchange="ComboBoxChange()"></select>
<br>
<br>
<table width="95%" border>
<tr>
<td width="20%" valign="top"><b>Row 1 Cell 1:</b></td>
<td width="75%" valign="top">Row 1 Cell 2</td></tr>
<tr>
<tr>
<td width="20%" valign="top"><b>Row 2 Cell 1:</b></td>
<td width="75%" valign="top">Row 2 Cell 2</td></tr>
<tr>
<tr>
<td width="20%" valign="top"><b>Row 3 Cell 1:</b></td>
<td width="75%" valign="top">Row 3 Cell 2</td></tr>
<tr>
</table>
<br><br>
<span id="SpanArea" class="FixedWidth">Click the ChangeSpanArea button to change this text</span>
<br>
<br>
<input type="checkbox" name="CheckBox" title="This is a checkbox" onclick="CheckBoxChange"> Click the checkbox
<br>
<br>
<input type="radio" name="Radio" title="This is a Radio button" onclick="CheckRadioButtons" CHECKED>
<input type="radio" name="Radio" title="This is a Radio button" onclick="CheckRadioButtons"> These are radio buttons
<BR>
<textarea style="overflow:auto" rows="7" name="TextArea" cols="70"></textarea><P align="right">
</body>
</html>
<message edited by ginolard on Thursday, December 07, 2006 1:30 AM>
|
|
|
|
gdewrance
-
Total Posts
:
591
- Scores: 3
-
Reward points
:
0
- Joined: 3/16/2006
-
Status: offline
|
RE: A basic HTA template
Thursday, December 07, 2006 1:25 AM
( permalink)
what happened to the closing code tag [/code]
|
|
|
|
Country73
-
Total Posts
:
754
- Scores: 10
-
Reward points
:
0
-
Status: offline
|
RE: A basic HTA template
Thursday, December 07, 2006 3:06 AM
( permalink)
Noticed you didn't have anything setup in the SUB for the Radio Buttons. (What you don't like Radio Buttons that much?) Added the "Value" to the radio buttons: <input type="radio" name="Radio" title="This is a Radio button" value="RadioOne" onclick="CheckRadioButtons" CHECKED> <input type="radio" name="Radio" title="This is a Radio button" value="RadioTwo" onclick="CheckRadioButtons"> These are radio buttons Then added this small bit of code to the "Sub CheckRadioButtons" If Radio(0).Checked THEN MsgBox Radio(0).Value ELSE MsgBox Radio(1).Value END IF
<html>
<title>HTA template</title>
<head>
<HTA:APPLICATION
APPLICATIONNAME="HTA Template"
SCROLL="yes"
SINGLEINSTANCE="yes"
WINDOWSTATE="normal"
>
</head>
<style>
BODY
{
background-color: buttonface;
Font: arial,sans-serif
margin-top: 10px;`
margin-left: 20px;
margin-right: 20px;
margin-bottom: 5px;
}
.button
{
width: 91px;
height: 25px;
font-family: arial,sans-serif;
font-size: 8pt;
}
td
{
font-family: arial,sans-serif;
font-size: 10pt;
}
#scroll
{
height:100%;
overflow:auto;
}
SELECT.FixedWidth
{
width: 17em; /* maybe use px for pixels or pt for points here */
}
</style>
<script language="VBScript">
Sub Window_OnLoad
'Code to run when HTA loads goes here
MsgBox "Hello and welcome to my HTA"
'Here we add values to the Combobox called ComboBox1
Set objOption = Document.createElement("OPTION")
objOption.Text = "FuzzyWuzzyBunny"
objOption.Value ="FuzzyWuzzyBunny"
ComboBox1.Add(objOption)
Set objOption = Document.createElement("OPTION")
objOption.Text = "FuzzyWuzzyKitten"
objOption.Value ="FuzzyWuzzyKitten"
ComboBox1.Add(objOption)
TextArea.InnerText="This is a text area"
End Sub
Sub ButtonClick
MsgBox "You clicked a button!"
End Sub
Sub ChangeSpanArea
If Not SpanArea.InnerText = "Text has been changed. Click the button again to change it back" Then
SpanArea.InnerText="Text has been changed. Click the button again to change it back"
Else
SpanArea.InnerText="Click the ChangeSpanArea button to change this text"
End If
End Sub
Sub ComboBoxChange
MsgBox "The Value of the Combobox is currently " & ComboBox1.Value
End Sub
Sub CheckBoxChange
If CheckBox.Checked Then
MsgBox "CheckBox is checked"
Else
MsgBox "CheckBox is not checked"
End If
End Sub
Sub CheckRadioButtons
If Radio(0).Checked THEN
MsgBox Radio(0).Value
ELSE
MsgBox Radio(1).Value
END IF
End Sub
</script>
<body>
<input class="button" TYPE=BUTTON value="TestButton" name="btnTestButton" onClick="ButtonClick">
<input class="button" TYPE=BUTTON value="ChangeSpanArea" name="btnChangeSpanArea" onClick="ChangeSpanArea">
<br>
<br>
<select size="1" class="FixedWidth" name="ComboBox1" onchange="ComboBoxChange()"></select>
<br>
<br>
<table width="95%" border>
<tr>
<td width="20%" valign="top"><b>Row 1 Cell 1:</b></td>
<td width="75%" valign="top">Row 1 Cell 2</td></tr>
<tr>
<tr>
<td width="20%" valign="top"><b>Row 2 Cell 1:</b></td>
<td width="75%" valign="top">Row 2 Cell 2</td></tr>
<tr>
<tr>
<td width="20%" valign="top"><b>Row 3 Cell 1:</b></td>
<td width="75%" valign="top">Row 3 Cell 2</td></tr>
<tr>
</table>
<br><br>
<span id="SpanArea" class="FixedWidth">Click the ChangeSpanArea button to change this text</span>
<br>
<br>
<input type="checkbox" name="CheckBox" title="This is a checkbox" onclick="CheckBoxChange"> Click the checkbox
<br>
<br>
<input type="radio" name="Radio" title="This is a Radio button" value="RadioOne" onclick="CheckRadioButtons" CHECKED>
<input type="radio" name="Radio" title="This is a Radio button" value="RadioTwo" onclick="CheckRadioButtons"> These are radio buttons
<BR>
<textarea style="overflow:auto" rows="7" name="TextArea" cols="70"></textarea><P align="right">
</body>
</html>
|
|
|
|
ginolard
-
Total Posts
:
1347
- Scores: 23
-
Reward points
:
0
- Joined: 8/11/2005
-
Status: offline
|
RE: A basic HTA template
Thursday, December 07, 2006 3:38 AM
( permalink)
OOps. I even created the Sub for it too! Anyway, this is meant to be a constantly-updating template. There are loads of other objects that can be added.
|
|
|
|
Snipah
-
Total Posts
:
1339
- Scores: 8
-
Reward points
:
0
- Joined: 11/1/2004
- Location: Scotland
-
Status: offline
|
RE: A basic HTA template
Tuesday, December 12, 2006 6:09 AM
( permalink)
|
|
|
|
ginolard
-
Total Posts
:
1347
- Scores: 23
-
Reward points
:
0
- Joined: 8/11/2005
-
Status: offline
|
RE: A basic HTA template
Tuesday, December 12, 2006 11:33 PM
( permalink)
Would like you that on your desk by 9am tomorrow morning Sir?
|
|
|
|
ickleric
-
Total Posts
:
92
- Scores: 0
-
Reward points
:
0
- Joined: 11/15/2006
-
Status: offline
|
RE: A basic HTA template
Thursday, December 21, 2006 2:25 AM
( permalink)
with the textarea when you submit it adds the text to the textfile. Is there anyway of when you submit it overwrites anything already in the text file?
|
|
|
|
ickleric
-
Total Posts
:
92
- Scores: 0
-
Reward points
:
0
- Joined: 11/15/2006
-
Status: offline
|
RE: A basic HTA template
Thursday, December 21, 2006 2:27 AM
( permalink)
never mind i've worked it out now. although i would like to know, is there anyway of displaying the contents of the text file in a textarea? thanks
|
|
|
|
ginolard
-
Total Posts
:
1347
- Scores: 23
-
Reward points
:
0
- Joined: 8/11/2005
-
Status: offline
|
RE: A basic HTA template
Tuesday, December 26, 2006 8:32 PM
( permalink)
Updated version with a button that fills the text area with the contents of an input file.
<html>
<title>HTA template</title>
<head>
<HTA:APPLICATION
APPLICATIONNAME="HTA Template"
SCROLL="yes"
SINGLEINSTANCE="yes"
WINDOWSTATE="normal"
>
</head>
<style>
BODY
{
background-color: buttonface;
Font: arial,sans-serif
margin-top: 10px;`
margin-left: 20px;
margin-right: 20px;
margin-bottom: 5px;
}
.button
{
width: 91px;
height: 25px;
font-family: arial,sans-serif;
font-size: 8pt;
}
td
{
font-family: arial,sans-serif;
font-size: 10pt;
}
#scroll
{
height:100%;
overflow:auto;
}
SELECT.FixedWidth
{
width: 17em; /* maybe use px for pixels or pt for points here */
}
</style>
<script language="VBScript">
Sub Window_OnLoad
'Code to run when HTA loads goes here
MsgBox "Hello and welcome to my HTA"
'Here we add values to the Combobox called ComboBox1
Set objOption = Document.createElement("OPTION")
objOption.Text = "FuzzyWuzzyBunny"
objOption.Value ="FuzzyWuzzyBunny"
ComboBox1.Add(objOption)
Set objOption = Document.createElement("OPTION")
objOption.Text = "FuzzyWuzzyKitten"
objOption.Value ="FuzzyWuzzyKitten"
ComboBox1.Add(objOption)
TextArea.InnerText="This is a text area"
End Sub
Sub ButtonClick
MsgBox "You clicked a button!"
End Sub
Sub ChangeSpanArea
If Not SpanArea.InnerText = "Text has been changed. Click the button again to change it back" Then
SpanArea.InnerText="Text has been changed. Click the button again to change it back"
Else
SpanArea.InnerText="Click the ChangeSpanArea button to change this text"
End If
End Sub
Sub ComboBoxChange
MsgBox "The Value of the Combobox is currently " & ComboBox1.Value
End Sub
Sub FillTextArea
Set objFSO=CreateObject("Scripting.FileSystemObject")
TextArea.InnerText=objFSO.OpenTextFile("c:\temp\test.txt",1).ReadAll
End Sub
Sub CheckBoxChange
If CheckBox.Checked Then
MsgBox "CheckBox is checked"
Else
MsgBox "CheckBox is not checked"
End If
End Sub
Sub CheckRadioButtons
If Radio(0).Checked THEN
MsgBox Radio(0).Value
ELSE
MsgBox Radio(1).Value
END IF
End Sub
</script>
<body>
<input class="button" TYPE=BUTTON value="TestButton" name="btnTestButton" onClick="ButtonClick">
<input class="button" TYPE=BUTTON value="ChangeSpanArea" name="btnChangeSpanArea" onClick="ChangeSpanArea">
<input class="button" TYPE=BUTTON value="FillTextArea" name="btnFillTextArea" onClick="FillTextArea">
<br>
<br>
<select size="1" class="FixedWidth" name="ComboBox1" onchange="ComboBoxChange()"></select>
<br>
<br>
<table width="95%" border>
<tr>
<td width="20%" valign="top"><b>Row 1 Cell 1:</b></td>
<td width="75%" valign="top">Row 1 Cell 2</td></tr>
<tr>
<tr>
<td width="20%" valign="top"><b>Row 2 Cell 1:</b></td>
<td width="75%" valign="top">Row 2 Cell 2</td></tr>
<tr>
<tr>
<td width="20%" valign="top"><b>Row 3 Cell 1:</b></td>
<td width="75%" valign="top">Row 3 Cell 2</td></tr>
<tr>
</table>
<br><br>
<span id="SpanArea" class="FixedWidth">Click the ChangeSpanArea button to change this text</span>
<br>
<br>
<input type="checkbox" name="CheckBox" title="This is a checkbox" onclick="CheckBoxChange"> Click the checkbox
<br>
<br>
<input type="radio" name="Radio" title="This is a Radio button" value="RadioOne" onclick="CheckRadioButtons" CHECKED>
<input type="radio" name="Radio" title="This is a Radio button" value="RadioTwo" onclick="CheckRadioButtons"> These are radio buttons
<BR>
<textarea style="overflow:auto" rows="7" name="TextArea" cols="70"></textarea><P align="right">
</body>
</html>
<message edited by Country73 on Friday, March 30, 2007 6:28 AM>
|
|
|
|