SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 1192 | Next

Joseph W. Lowery

"Dreamweaver CS3 Bible"

I recently built a site for which the client wanted the time to be shown in a
particular way, for example, 9PM. The closest format in Dreamweaver displays that time as 9:00:00 PM. To
show the time as desired, I needed to add some hand-coding.
This site uses an ASP server model with VBScript as its scripting language. My first task was to show only the
hour portion of time. VBScript has a function that does exactly this, aptly named Hour(). When applied to
my dynamic data code, it looks like this:
<%=Hour(rsEvents.Fields.Item(???showTime???).Value) %>
Unfortunately, the Hour() function returns values according to a 24-hour clock (also known as military
time), so 9PM becomes 21. The second problem is that the Hour() function only returns a number and does
not include an AM or PM designation. To solve these problems, I wrote a small ASP routine that incorporated
the Dreamweaver-generated code:
<%
Dim myTime, myShift
myShift = ???AM???
myTime = Hour(rsEvents.Fields.Item(???showTime???).Value)
If (myTime > 12) Then
myTime = myTime-12
myShift = ???PM???
End If
Response.write myTime & myShift
%>
Making Images Dynamic
The Web is both a textual and a visual medium. You??™ve seen how Dreamweaver replaces static text with
dynamic text from a database.


Pages:
1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204