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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Time in a form

Status
Not open for further replies.

RadioX

IS-IT--Management
May 15, 2001
145
US
I have two form fields. In each one of them I want to display time from 12 to 1 so I can have a start time and end time inserted into my database. How would I go about doing this is a form, select option type method.

Thanks
 
This should work. You could hard code the whole thing (1-12 and 0-59) but it's less typing to put it in a loop.

<select name = "fHour">
<cfloop From = "1" to = "12" index = "iHour">
<cfoutput><option value = "#iHour#">#iHour#</option></cfoutput>
</cfloop>
</select>
<select name = "fMinute">
<cfloop from = "0" to = "59" index = "iMinute">
<cfoutput><option value = "#iMinute#">#iMinute#</option></cfoutput>
</cfloop>
</select>

When you put it in your DB or use it how ever you are #form.fHour#:#form.fMinute# will display the time the user selected. You didn't say anything about AM or PM so I didn't write for that.

Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so.
-Douglas Adams (1952-2001)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top