Forum Moderators: open

Message Too Old, No Replies

Auto date select on drop downs - ?

getting the dropdown to select todays month and date

         

stavs

5:49 pm on Mar 19, 2002 (gmt 0)

10+ Year Member



I am trying to make my date input fields more intelligent - I am using one drop-down menu for months and another for date.

I'm looking for a way so that the current month and date is auto selected - rather than the user just seeing 'Month' and '01' (which are the default selections), I want them to see March and 19.

Can anyone shed any light on this - I can't find a solution, but it can't be that difficult.

...can it?

txbakers

7:11 pm on Mar 19, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's not that difficult, but it involves some javascript coding.

If you go to www.javascripts.com you'll find hundreds (thousands?) of ready made scripts. Look for one involving date and time and you'll probably find one you can adapt.

The procedure is to get the current month and year, and compare them to your dropdown box selectedIndex.Value for as many times as there are values. When you find a match, you set the select box to that selectedIndex.

Happy hunting. If you have trouble finding one, I can post a similar "pre-set" drop down box.