Copy the following file and execute it in your browser. What's wrong with it and why? Can you fix it?

 <html><head><title>link</title> <script language="JavaScript"> function addem(){   var n = 2;   var y = 3;   document.write( n + y , "<br>"); } </script> </head> <body bgcolor=red> <a href="javascript:addem()">Click here</a> <h2>Hello</h2> </body> </html> 

Write a function that will calculate and return the amount that should be paid as a tip for a resturant bill. The tip will be 20 percent of the total bill.


Create a function called changeColor() that will be called when the user presses one of two buttons . The first button will contain the text " Press here for a yellow background ". The second button will contain the text " Press here for a light green background ". The function will take one parameter, a color. Its function is to change the background color of the current document.


What is recursion? What is the danger of using it?


Write a function that returns the total cost of any number of buckets of paint. Ask the user how many buckets he is going to buy and for the cost of one bucket. Ask him the color of the paint. Calculate and return what he owes. Change the color of the font to the color of the paint.

JavaScript by Example
JavaScript by Example (2nd Edition)
ISBN: 0137054890
EAN: 2147483647
Year: 2003
Pages: 150
Authors: Ellie Quigley

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net