Tuesday 8 December 2009

3.9 Client Side Programming

My javascript application uses three functions declared in the head of the HTML document. The first, ‘newsorsport’, produces a prompt box asking the user if they are interested in news or sport and requesting they enter 1 for news or 2 for sport. The user's input is declared as a variable and converted to an integer and depending on the outcome either the function ‘area’ or ‘sporttype’ is called. Both these functions request further input from the user via a prompt box and display a link depending on the input.


I found the following aspects of creating the program particularly challenging:
  • Whether to put all the script in the body section of the HTML document or whether to use functions scripted in the head part and then call these in the body
  • The synatx of If statements. In VBA (which I have some limited experience of) 'If, Then Else' is used whereas in Javascript just the word 'If' is required
  • Getting the curly brackets in the correct place
  • Remembering to use double equals signs (==)
  • Getting the anchor tagged URLs to work. They need to be in the paragraph tag and the whole phrase needs to sit within double quotation marks whereas the URL is within single quotes
The fruits of all my labours (and frustrations) can be found here.

No comments:

Post a Comment