Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date combo boxes populated with current date 1

Status
Not open for further replies.

birdycarolyn

Technical User
Apr 9, 2002
8
US
Hello All,

I'm new to ASP, so please bear with me if this is simple.

I have a series of combo boxes that are filled with hard-coded data (Month, Day, Hour). When someone accesses the page, I'd like for the current month, day and hour to populate the combo boxes so the user can avoid a having to select them.

Any help would be greatly appreciated.
Carolyn
 
For this purpose I have written the following function. Rather than hard coding your content, you may want to create an 2 dimensional array for each of them. First column should represent the option value while second one is for the text in the combo box.

dim month(1,11)
month(0,0) = 0
month(1,0) = "January"
month(0,1) = 1
month(1,1) = "February"
month(0,2) = 2
month(1,2) = "March"
...

response.write make_list(month,"NAME=MONTH SIZE=1",month(now))



function make_list(listbox_source,listbox_params,default_value)
dim output,i
output = &quot;<Select &quot;&listbox_params&&quot;>&quot; & chr(13)
if isArray(listbox_source) then
for i = 0 to ubound(listbox_source,2)
output = output & &quot;<OPTION Value=&quot;&listbox_source(0,i)&&quot;>&quot; & listbox_source(1,i) & chr(13)
next
end if
if default_value <> &quot;&quot; then
output = replace(output,&quot;Value=&quot;&default_value,&quot;Value=&quot;&default_value&&quot; SELECTED&quot;) & chr(13)
end if
output = output & &quot;</Select>&quot; & chr(13)
make_list = output
end function
 
Wow, thanks for the quick response! I really appreciate it!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top