473,569 Members | 2,698 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Create Pulldown Menus for Month/Day/Year in HTA

Hello all. Consider the following HTA:

<html>
<head>
<title>Date Pulldowns</title>
<HTA:APPLICATIO N
ID="HTAUI"
APPLICATIONNAME ="Date Pulldowns"
SCROLL="no"
SINGLEINSTANCE= "yes"
WINDOWSTATE="ma ximized">
</head>

<SCRIPT language="VBScr ipt">
Dim fromMonth, fromDay, fromYear, toMonth, toDay
Dim toYear, fromDate, toDate
Sub Window_Onload
self.Focus()
self.ResizeTo 400,200
self.MoveTo 400,150
End Sub

Sub FromMonthSelect Sub
fromMonth = FromMonthSelect ion.Value
End Sub

Sub FromDaySelectSu b
fromDay = FromDaySelectio n.Value
End Sub

Sub FromYearSelectS ub
fromYear = FromYearSelecti on.Value
End Sub

Sub ToMonthSelectSu b
toMonth = ToMonthSelectio n.Value
End Sub

Sub ToDaySelectSub
toDay = ToDaySelection. Value
End Sub

Sub ToYearSelectSub
toYear = ToYearSelection .Value
End Sub

Sub DisplayDatesSub
fromDate = fromMonth & "/" & fromDay & "/" & fromYear
toDate = toMonth & "/" & toDay & "/" & toYear
MsgBox "From:" & vbTab & fromDate & vbCrlf & "To:" & vbTab & toDate
End Sub
</SCRIPT>

<BODY STYLE="font:6 pt arial; color:white;
filter:progid:D XImageTransform .Microsoft.Grad ient
(GradientType=1 , StartColorStr=' #000000', EndColorStr='#0 000FF')">
<p align="left"><f ont face="serif" size="4"><b>
&nbsp;&nbsp;&nb sp;&nbsp;&nbsp; &nbsp;&nbsp;
From:
&nbsp;&nbsp;&nb sp;&nbsp;&nbsp; &nbsp;&nbsp;&nb sp;&nbsp;&nbsp;
&nbsp;&nbsp;&nb sp;&nbsp;&nbsp; &nbsp;&nbsp;&nb sp;&nbsp;&nbsp;
&nbsp;&nbsp;
To:
<br>
<align="left" >
<select id="FromMonthSe lection" onChange="FromM onthSelectSub">
<option value="0"></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>

<select id="FromDaySele ction" onChange="FromD aySelectSub">
<option value="0"></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>

<select id="FromYearSel ection" onChange="FromY earSelectSub">
<option value="0"></option>
<option value="2007">20 07</option>
<option value="2006">20 06</option>
<option value="2005">20 05</option>
<option value="2004">20 04</option>
<option value="2003">20 03</option>
<option value="2002">20 02</option>
</select>
&nbsp;&nbsp;

<align="left" >
<select id="ToMonthSele ction" onChange="ToMon thSelectSub">
<option value="0"></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>

<select id="ToDaySelect ion" onChange="ToDay SelectSub">
<option value="0"></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>

<select id="ToYearSelec tion" onChange="ToYea rSelectSub">
<option value="0"></option>
<option value="2007">20 07</option>
<option value="2006">20 06</option>
<option value="2005">20 05</option>
<option value="2004">20 04</option>
<option value="2003">20 03</option>
<option value="2002">20 02</option>
</select>

<p align="left">
<input id=DisplayDates Button type="button" value="Display Dates"
name="DisplayDa tes_button"
onClick="Displa yDatesSub">
<p>
</BODY>
</html>

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.
Thanks!

- Dave

Dec 29 '06 #1
20 10959

Highlander wrote:
Consider the following HTA:
I'd rather not. You posted it to c.i.w.a.h where it's off-topic
because:

It's a HTA (spawn of pure evil) rather than HTML
It's a HTML, thus not suitable for "web" use, as opposed to M$'s little
play-nice-with-everyone sandpit.
It uses VBScript so it's IE-restricted
The HTML is a bit poor
The CSS is a bit poor

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:
HTML isn't a programming language, it's fundamentally a static text
markup language. So stick static things into it statically.

If you want to generate this programmaticall y (probably overkill for
days and months, but the principle isn't bad) then do it with some
server-side program that's _external_ to the HTML document itself (and
it's only a line or two of ASP, even ASP/VBScript).

Embedding executables into static documents is only sensible if you're
deliberately trying to obfuscate things, or you're drawing Hilbert
curves.

Dec 29 '06 #2
"Highlander " <tr******@msn.c omwrote in message
news:11******** *************@k 21g2000cwa.goog legroups.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:APPLICATIO N
ID="HTAUI"
APPLICATIONNAME ="Date Pulldowns"
SCROLL="no"
SINGLEINSTANCE= "yes"
WINDOWSTATE="ma ximized">
<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:D XImageTransform .Microsoft.Grad ient
(GradientType=1 , StartColorStr=' #000000', EndColorStr='#0 000FF')">
<font face="serif" size="4">
&nbsp;&nbsp;&nb sp;&nbsp;&nbsp; &nbsp;&nbsp;
<b>From:</b>
&nbsp;&nbsp;&nb sp;&nbsp;&nbsp; &nbsp;&nbsp;&nb sp;&nbsp;&nbsp;
&nbsp;&nbsp;&nb sp;&nbsp;&nbsp; &nbsp;&nbsp;&nb sp;&nbsp;&nbsp;
&nbsp;&nbsp;
<b>To:</b>
<br>
<select id="FromMonth" onChange="Selec ted('FromMonth' )">
<script type="text/vbscript">
document.write( optMDY(0))
</script>
</select>

<select id="FromDay" onChange="Selec ted('FromDay')" >
<script type="text/vbscript">
document.write( optMDY(1))
</script>
</select>

<select id="FromYear" onChange="Selec ted('FromYear') ">
<script type="text/vbscript">
document.write( optMDY(2))
</script>
</select>

&nbsp;&nbsp;

<select id="ToMonth" onChange="Selec ted('ToMonth')" >
<script type="text/vbscript">
document.write( optMDY(0))
</script>
</select>

<select id="ToDay" onChange="Selec ted('ToDay')">
<script type="text/vbscript">
document.write( optMDY(1))
</script>
</select>

<select id="ToYear" onChange="Selec ted('ToYear')">
<script type="text/vbscript">
document.write( optMDY(2))
</script>
</select>

<br><br>
<input type="button" value="Display Dates" onClick="Displa yDates()">
</body>
</html>
There's no such tag as <align="left" >
(it's the default alignment anyway)
and you use of &nbsp;
for spacing is not recommended;
consider using a <table>.

Also, you may want to use 2-digit months and days.
Dec 29 '06 #3
"Andy Dingley" <di*****@codesm iths.comwrote in message
news:11******** **************@ k21g2000cwa.goo glegroups.com.. .
>
Highlander wrote:
Consider the following HTA:

I'd rather not. You posted it to c.i.w.a.h where it's off-topic
because:

It's a HTA (spawn of pure evil) rather than HTML
Huh?
It's a HTML, thus not suitable for "web" use, as opposed to M$'s little
play-nice-with-everyone sandpit.
HTA's are (primarily) meant to run locally.
It uses VBScript so it's IE-restricted
So, this is a VBScript newsgroup.
The HTML is a bit poor
Agreed.
The CSS is a bit poor
Agreed.
>
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:

HTML isn't a programming language, it's fundamentally a static text
markup language. So stick static things into it statically.
VBScript is the programming language.
If you want to generate this programmaticall y (probably overkill for
days and months, but the principle isn't bad) then do it with some
server-side program that's _external_ to the HTML document itself (and
it's only a line or two of ASP, even ASP/VBScript).
HTA's are not an ASP topic.
Embedding executables into static documents is only sensible if you're
deliberately trying to obfuscate things, or you're drawing Hilbert
curves.
Huh? What does this have to do with anything?
Dec 29 '06 #4
"McKirahan" <Ne**@McKirahan .comwrites:
"Andy Dingley" <di*****@codesm iths.comwrote in message
news:11******** **************@ k21g2000cwa.goo glegroups.com.. .
>It uses VBScript so it's IE-restricted

So, this is a VBScript newsgroup.
What part of comp.infosystem s.www.authoring.HTML, or alt.HTML do you not
understand?

You cross-posted this to three groups; one of them is relevant, the others
are not. Followups set.
>HTML isn't a programming language, it's fundamentally a static text
markup language. So stick static things into it statically.

VBScript is the programming language.
You posted to two different HTML groups also.

sherm--

--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
Dec 29 '06 #5
McKirahan,

Thanks for your suggestions!

Andy Dingley wrote:
Highlander wrote:

Consider the following HTA:

I'd rather not. You posted it to c.i.w.a.h where it's off-topic
Sherm Pendley wrote:
You cross-posted this to three groups; one of them is relevant, the others
are not. Followups set.
....

Off-topic? Not relevant?

A search in comp.infosystem s.www.authoring.html for the word "HTA":
39 results

A search in alt.html for the word "HTA":
70 results

Furthermore, a "date picker" pulldown menu of Month/Day/Year selections
is a *very* common element on websites; so it stands to reason that
HTML related newsgroups (such as these two that I posted to) just might
have info on this type of dropdown.

Dec 29 '06 #6
Replied to [Highlander]s message :
Hello all. Consider the following HTA:

<html>
<head>
<title>Date Pulldowns</title>
<HTA:APPLICATIO N
ID="HTAUI"
APPLICATIONNAME ="Date Pulldowns"
SCROLL="no"
SINGLEINSTANCE= "yes"
WINDOWSTATE="ma ximized">
</head>

I am not very good at VBs so i made this in Js. Insert this at top of your VBS script
tag :

There is a variable named elementNames.. The syntax is like :
"ID of element|LengthA ndValueOptions, ID|LengthAndVal ue etc.etc...

<script language="JScri pt">
window.onload=M akee
elementNames="F romDaySelection |31,FromMonthSe lection|12,ToMo nthSelection|12 ,ToDaySelection |31"

function Makee(){
eN=elementNames .split(",");num m=new Array()
for(indX=0;indX <eN.length;indX ++){
numm[indX]=parseInt(eN[indX].substring(eN[indX].length-2,eN[indX].length))
eN[indX]=document.getEl ementById(eN[indX].substring(0,eN[indX].length-3));
}
for(aIx=0;aIx<e N.length;aIx++) {
con = document.create Element("option ");
eN[aIx].options.add(co n);
for(aIxx=1;aIxx <(numm[aIx]+1);aIxx++){
cTion = document.create Element("option ");
eN[aIx].options.add(cT ion);
cTion.innerText = aIxx;
cTion.value = aIxx;
}}}
</script>

Dec 29 '06 #7
Highlander wrote:
McKirahan,

Thanks for your suggestions!

Andy Dingley wrote:
>Highlander wrote:
>>Consider the following HTA:
I'd rather not. You posted it to c.i.w.a.h where it's off-topic

Sherm Pendley wrote:
>You cross-posted this to three groups; one of them is relevant, the others
are not. Followups set.

...

Off-topic? Not relevant?

A search in comp.infosystem s.www.authoring.html for the word "HTA":
39 results
A topic of discussion doesn't become on-topic in a newsgroup because
people may mention it in passing while discussing something that is on
topic, or because other people have already raised it in off-topic postings.

HTA is for running apps on local computers. C.i.w.a.h is about authoring
HTML for the Web. They're mutually exclusive.
A search in alt.html for the word "HTA":
70 results
Alt.html is about anything HTML related, so I don't see any problem with
bringing up the topic there. OMMV (others' mileage may vary).
>
Furthermore, a "date picker" pulldown menu of Month/Day/Year selections
is a *very* common element on websites;
but not as an HTA.
so it stands to reason that
HTML related newsgroups (such as these two that I posted to) just might
have info on this type of dropdown.
People in a wine newsgroup might know something about cheese, but ask a
cheese-related question in a cheese newsgroup and leave the wine
newsgroup for people to discuss wine. Otherwise the point of having
separate newsgroups for so many topics is kind of defeated.

It's one thing if there isn't *any* obvious newsgroup to post a question
in, or if a newsgroup specific to the subject exists but has no traffic
other than spammers. But this isn't one of those situations. Frankly, I
would think that one of the microsoft.* newsgroups related to
"inetexplor er" would be the best bet.
Dec 29 '06 #8
Replied to [Harlan Messinger] :

Can you tell me which server are you using to subscribe to this NG ?

→ Ayush
Dec 29 '06 #9
It's not clear whether you've got your
answer yet, in all this confusion. :)

So just in case....
In addition to McKirihan's method of
looping through pre-existing options, you
can also load them and clear them dynamically.

It's awkward because it's non-intuitive.
The DOM treats an option as an object, so you have
to "create" them and add them to a SELECT::

Dim Opt

Set Opt = document.create Element("OPTION ")
Opt.text = '-- text of option here.
Opt.value = '-- hidden value here.
FromMonthSelect ion.add Opt
Set Opt = Nothing

To clear options just use:

FromMonthSelect ion.length = 0


Dec 30 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3330
by: Ken Fine | last post by:
I want my application to maintain a directory tree based on months and years, e.g.: 2004 January file file file February file
2
1613
by: Mike | last post by:
Hello, I'm looking for an example of doing a page with pulldown menus, where the user selects a choice from the first pulldown, then based on that input, another appears, then the user selects from that one, and based on that input, yet another appears, etc... Thanks, Mike
9
2137
by: flarkblark | last post by:
I recently had the displeasure of looking at the code required to implement the pop-up menus used in a pulldown menu system for a webpage. The sheer amount of Javascript required was amazing and frankly revolting. It is as though the software "engineers" have been thrown out and replaced with "programmers". That is to say, it is a...
0
521
by: Gufus | last post by:
Afternoon Spartanicus, Saturday September 10 2005, Spartanicus writes to Gufus: > From: invalid@invalid.invalid > NOSPAM.gbbsg@shaw.ca (Gufus) wrote: >> Now, can you post some sample code of drop down menus? > I can tell you what you should look for. If it's for a site
2
9821
by: Steven (dotnet newbie) | last post by:
Hello. I am trying to create a database from an XML file. I am able to create a dataset from the XML doc, but how can I create a database schema from the dataset and populate the database? Or is this even possible using VS.NET 2003? Part of the XML file follows. Thanks for any help. Steven VS.NET 2003 and C# newbie! ----- Part of...
2
1260
by: Thrasher Remailer | last post by:
Using the example at http://www.w3schools.com/dhtml/tryit.asp?filename=trydhtml_menu10 as a base, how can I extend this code to handle tiered ( cascading ) pulldowns? For example, hovering over 'Scripting' opens a pulldown with 5 items. I'd like to add a submenu to 'DHTML' that would appear to the immediate right and top-level with...
1
1764
by: leicklda | last post by:
Hi there, I'm very novice to web design. I'm trying to make a pulldown menu, but the formatting keeps getting screwed up when you roll the mouse over it. Please see www.boundarysys.com for what I'm talking about. Before the mouse touches the pulldown, the vertical height of the menubar is perfect. As soon as the mouse rolls over it,...
4
12990
by: Billy Barth | last post by:
I would like to create a RSS feed from my Access Database. I have an Access table for news which has the article title, date, and story in it. What I would like to do is pull the data from there into an xml file to create the RSS feed, so when users upload a news story it automatically updates in the xml file. Can this be done with asp? and...
7
4098
by: Lucas_london via AccessMonster.com | last post by:
Hi I have set up a database/tables in Access based on daily timeseries data. However I would like to create two additional columns in the table as a basis to pull the data on a weekly and monthly series basis. Currently, in excel I am using the weekday and EOMONTH functions to create the flags/indicator in my excel dataset: (Cells in...
0
7698
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8122
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7970
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1213
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
937
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.