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.
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)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.