|
Posted by McKirahan on 12/29/06 16:43
"Highlander" <tron9901@msn.com> wrote in message
news:1167406316.195202.84900@k21g2000cwa.googlegroups.com...
> Hello all. Consider the following HTA:
[snip]
>
> The script works fine, but I'm wondering if there's any way to
> dynamically populate the pulldown lists with all the months of the
> year, days of the month, etc. - rather than have to list each one out
> like this:
>
> <option value="1">1</option>
> <option value="2">2</option>
> <option value="3">3</option>
> <option value="4">4</option>
> etc.
> etc.
> etc.
>
> Any suggestions would be greatly appreciated.
Will this help? This cuts the code size in half.
<html>
<head>
<title>Date Pulldowns</title>
<HTA:APPLICATION
ID="HTAUI"
APPLICATIONNAME="Date Pulldowns"
SCROLL="no"
SINGLEINSTANCE="yes"
WINDOWSTATE="maximized">
<script type="text/vbscript">
Option Explicit
'*
Const cOPT = "<option value='?'>?</option>"
'*
Dim fromMDY(2)
Dim toMDY(2)
Dim optMDY(2)
optMDY(0) = "<option value='0'></option>"
optMDY(1) = "<option value='0'></option>"
optMDY(2) = "<option value='0'></option>"
Dim i
'*
For i = 1 To 12
optMDY(0) = optMDY(0) & vbCrLf & Replace(cOPT,"?",i)
Next
For i = 1 To 31
optMDY(1) = optMDY(1) & vbCrLf & Replace(cOPT,"?",i)
Next
For i = Year(Date)+1 To Year(Date)-4 Step -1
optMDY(2) = optMDY(2) & vbCrLf & Replace(cOPT,"?",i)
Next
Sub Selected(What)
Select Case What
Case "FromMonth"
fromMDY(0) = FromMonth.Value
Case "FromDay"
fromMDY(1) = FromDay.Value
Case "FromYear"
fromMDY(2) = FromYear.Value
Case "ToMonth"
toMDY(0) = ToMonth.Value
Case "ToDay"
toMDY(1) = ToDay.Value
Case "ToYear"
toMDY(2) = ToYear.Value
End Select
End Sub
Sub DisplayDates()
MsgBox "From:" & vbTab & Join(fromMDY,"/") & vbCrlf _
& "To:" & vbTab & Join(toMDY,"/")
End Sub
Sub Window_Onload()
self.Focus()
self.ResizeTo 400,200
self.MoveTo 400,150
End Sub
</script>
</head>
<body style="font:6 pt arial; color:white;
filter:progid:DXImageTransform.Microsoft.Gradient
(GradientType=1, StartColorStr='#000000', EndColorStr='#0000FF')">
<font face="serif" size="4">
<b>From:</b>
<b>To:</b>
<br>
<select id="FromMonth" onChange="Selected('FromMonth')">
<script type="text/vbscript">
document.write(optMDY(0))
</script>
</select>
<select id="FromDay" onChange="Selected('FromDay')">
<script type="text/vbscript">
document.write(optMDY(1))
</script>
</select>
<select id="FromYear" onChange="Selected('FromYear')">
<script type="text/vbscript">
document.write(optMDY(2))
</script>
</select>
<select id="ToMonth" onChange="Selected('ToMonth')">
<script type="text/vbscript">
document.write(optMDY(0))
</script>
</select>
<select id="ToDay" onChange="Selected('ToDay')">
<script type="text/vbscript">
document.write(optMDY(1))
</script>
</select>
<select id="ToYear" onChange="Selected('ToYear')">
<script type="text/vbscript">
document.write(optMDY(2))
</script>
</select>
<br><br>
<input type="button" value="Display Dates" onClick="DisplayDates()">
</body>
</html>
There's no such tag as <align="left">
(it's the default alignment anyway)
and you use of
for spacing is not recommended;
consider using a <table>.
Also, you may want to use 2-digit months and days.
[Back to original message]
|