Q:

Using JavaScript Functions to Manipulate HTML

I'm having a spot of trouble in making my functions work and my book seems to be pure rubbish. I'm sure that the error is purely syntax, although it may be something more.
Here is the JavaScript that I've written. Obviously the banner function doesn't provide full functionality, but it should do something. Currently I just get a broken image link.
function displayBanner(currentDate) {
    var imgSrc = defaultLogo;
    if  (currentDate.getMonth() == 1)
        imgSrc = "winterLogo";
    return ("<img src='" + imgSrc + ".gif'>");
}

function calcDaysToSale(currentDate) {
    var saleDay = new Date();
    saleDay.setDate(15);    // sets the sale date to the 15th of the current month

    // Subtracts the days remaining until the sale.
    // If the number is negative, the sale is over.
    var Days = saleDay.getDate()-currentDate.getDate();
    if (Days < 0) {
        return "The sale has ended.";
    }
    else {
        return Days;
    }
}

Now, I'm thinking that the reason for this is that it isn't being called correctly. Here is the function I've embedded in the head of the html page:
<script type="text/javascript" src="flowers.js"></script>
    <script type="text/javascript">
        function pageSetup() {
          var today = new Date(); // this creates a date object with today's date
          var banner = displayBanner(today); // *should* call the displayBanner     function

          var days = calcDaysToSale(today); // *should* call the function using today's date
          document.sale.saleMessage.value = days; // *should* set the value to days.

      // Obviously none of it works.

    }

 </script>

I call pageSetup() at the bottom of my page. I posted the full html code below.
This may be, and I'm pretty sure it is, purely a syntax problem. However, the things that I've thought to Google and look up in my book haven't led me to any answers.
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Carol's Flowers</title>
<link href="flowers.css" rel="stylesheet" type="text/css" />
   <script type="text/javascript" src="flowers.js"></script>
    <script type="text/javascript">
        function pageSetup() {
          var today = new Date(); // this creates a date object with today's date
          var banner = displayBanner(today); // *should* call the displayBanner function

          var days = calcDaysToSale(today); // *should* call the function using today's date
          document.sale.saleMessage.value = days; // *should* set the value to days.

          // Obviously none of it works.

        }

     </script>

</head>

<body  class="oneColLiqCtrHdr">

<div id="container">
  <div id="header">
    <p><img name="myBanner" src="banner" id="myBanner" alt="Carol's Flowers" />
      <!-- end #header -->
    </p>
    <div id="links"><a href="#">Home</a> | <a href="#">General Arrangements</a> | <a href="#">Seasonal Designs</a> | <a href="#">Custom Orders</a> | <a href="#">Location</a></div>
  </div>
  <div id="mainContent">
    <table id="mainTable">
    <tr>
       <td width="201"><h1><img src="Flowers.JPG" alt="Random Flowers" width="200" height="255" /></h1></td>
       <td width="687">
    <p>Here at Carol's Flowers, we believe that there is a perfect floral arrangment for every occasion! Take a look around and see if there is anything you like. If we don't already have it, then we will create it for you!</p></td>
    </script>
    </tr>
    </table>
    <!-- end #mainContent --></div>
  <div id="footer">
    <p> <form name="sale" id="sale">
      Days Until Mid Month Madness Sale : 
      <input type="text" name="saleMessage" id="saleMessage" /></form></p>
    <!-- end #footer --></div>
<!-- end #container --></div>

<!-- I am trying to run the script here -->
<script type="text/javascript">
    pageSetup();
</script>

</body>
</html>

A:

Your displayBanner function looks fine, but make sure of the following:

The html string it returns is actually added to the document correctly. Post your code of how you do this if you're not sure.
the variable defaultLogo is defined.
The string you end up using for the src of the image is valid URL that goes to the image you want.

You set the variable banner to contain the html src returned from the displayBanner function, but you don't actually do anything with it in the code you've posted. Try adding
document.write( displayBanner(today) );

to the html document where you want the image to appear for a quick fix, or put this somewhere in your javascript, using the id of the element you want the image to appear inside.
document.getElementById("desired_element_id").innerHTML = displayBanner(today);

For the other part, again your function looks fine, just make sure you're applying it correctly to the document. Try adding this to your pageSetup function.
document.getElementById("saleMessage").value = days;

EDIT: I just tested your code. Make sure you're actually including the 'flowers.js' file by putting some alerts in it and seeing if they show up when you open the main document. Also, I still can't find anywhere where 'defaultLogo' is defined, so that could be causing your image src problem.

