HTML and CSS Reference
In-Depth Information
You can call these two functions to display the date and time text strings in the
show-
Date
and
showTime
fields of the Web form. To call the functions, you first must create a
link to the
functions.js
file.
To call the showDate() and showTime() functions:
◗
1.
Return to the
clock.htm
file in your text editor.
◗
2.
Directly above the opening
<script>
tag for the embedded script, insert the fol-
lowing external
script
element:
<script type=”text/javascript” src=”functions.js”></script>
◗
3.
In the embedded
script
element, replace the placeholder value in the
dateNow
field with the following:
showDate(today)
◗
4.
In the embedded
script
element, replace the placeholder value in the
timeNow
field with the following:
showtime(today)
Figure 11-11 shows the revised code for the
clock.htm
file.
Figure 11-11
inserting the showdate() and showtime() functions
link to the
functions.js file
display the text of the current
date and current time
◗
5.
Save your changes to the file.
◗
6.
Reopen or refresh
clock.htm
in your Web browser. Figure 11-12 shows the revised
date and time value in the page's Web form.
Figure 11-12
revised date and time values
date string generated by
the showDat
e
() function
time string
g
enerated by
the showTime() function
altafulla/Shutterstock.com; jbdphotography/Shutterstock.com