I am working on an assignment from the book ‘New Perspectives: HTML, CSS and DHTML’ and I am unable to get the code to work. This is an online class and this book is not a desirable choice for this type of class. Basically I am to write code to use a provided java script to display an image and a date. The java file has two functions showDateTime() and get-Map(). I have the following code in the head section:
<script src="datetime.js" type="text/javascript"></script>
<script type="text/javascript">
function datetime(timeStr, mapNum){
alert(mapNum);
/*
timeStr is a text string containing the current date and time
mapNum is the number of the map to display in the planisphere
*/
var timeStr = showDateTime();
var mapNum = get-map();
}
</script>
I believe this simply assigns the two variables the return value of the function to be used in the code. This is the code that is supposed to display an image from a collection names sky0.jpg to sky23.jpg by getting the map number from the function. It also returns the system’s date/time. Here is the code I am using:
<div id="maps">
<!-- <img id="sky" src="sky0.jpg" alt="" /> original code to be replaced by the script -->
<script type="text/javascript"
document.write('<img id="sky" src="sky' + mapNum + '.jpg" alt=" " />');
</script>
<img id="mask" src="mask.gif" alt="" />
<div id="datetime">
<script type="text/javascript">
document.write(timeStr);
</script>
</div>
</div>
My problem is that nothing happens, no image, no date. If anybody could shed light on what I am doing wrong it sure would be appreciated. I do not have a lot of hair to pull out.