Display hours in select box with am/pm using coldfusion
Display hours in select box with am/pm using coldfusion.
Select Hour :-
<select name="starthour" style="padding:5px;">
<cfset curtime = TimeFormat(Now(),'HH')>
<cfset starttime = 00>
<cfset endtime = 23>
<cfset endloop = (starttime + endtime)>
<cfloop from="#starttime#" to="#endloop#" index="hour">
<cfset showtime = hour & ':00:00'>
<option value="#hour#"<cfif curtime eq hour> selected="selected"</cfif>>#TimeFormat((showtime),'hh tt')#</option>
</cfloop>
</select>
</cfoutput>
Select Hour :-
<select name="starthour" style="padding:5px;">
<cfset curtime = TimeFormat(Now(),'HH')>
<cfset starttime = 00>
<cfset endtime = 23>
<cfset endloop = (starttime + endtime)>
<cfloop from="#starttime#" to="#endloop#" index="hour">
<cfset showtime = hour & ':00:00'>
<option value="#hour#"<cfif curtime eq hour> selected="selected"</cfif>>#TimeFormat((showtime),'hh tt')#</option>
</cfloop>
</select>
</cfoutput>
Comments
Post a Comment