Welcome

Use all lower case! Notice that if you spell male or female incorrectly, the color does not change.


The Script

  <html>
   <head>
  <SCRIPT type="text/javascript">
    function askuser()
     {
       answer=prompt("Are you Male or Female?")
       if ( answer == "female")
          {document.bgColor="pink"}
       if(answer == "male")
          {document.bgColor="lightblue"}
      }
  </script>
  </head>
  <body bgcolor="lightyellow">
    <h1>Welcome</h1>
    <form>
      <input type="button" 
	  value="Identify your Sex"  
	  onClick="askuser()">
    </form>
  </body
  </html>

This one was a little tough to get. I hope you were successful. You needed to change out the text in a few places, but the main thing was that you needed to change the outputs from an alert box to the document.bgColor statements to get the effect.

Please close this wondow to return to JavaScript Primer 21