Starting from scratch, I began typing some simple JavaScipt code into DreamWeaver. I used some variables, some functions, and called those functions, as well as using the “document.write” script to write some text to the document. I also used some of the math functions that are available in the “document.write” script.
Below is the screenshot I took of this practice. On the left is all of the code that I typed out for the page. On the right is the webpage itself. On the webpage, you can see where I used the “document.write” script and used my variables for the prices of the items. You can then tell where I used the math function to add the Mac and iPhone variables together and subtract 100 to get the discounted price. Directly below that, I used HTML to add the text “Want to know more about the Mac you’re using?”, and I then created a form to make the three buttons below the text. Those buttons each have an onClick event handler that calls the functions that I created in the <head></head> portion of the document. When you click these buttons, it displays a different alert for each. These alerts (and which button brings each up) are shown at the bottom of the document. I used Photoshop to add these alert screenshots onto the main screenshot of the code and display page.
After I did this little practice exercise, I continued where I left off in Chapter 6 at the “Data Type Conversions” section.