Tuesday 8 December 2009

Session 9: client-side programming

INM348 - Digital Information Technologies and Architectures
 
In this session we looked at our first 'direct' programming language, Javascript. It's a language that enables us to create 'client-side' applications, enabling us to carry out certain tasks  - like asking for a user's input - locally rather than having to keep sending information back and forth from a central server. Done in the right way, this client-side programming can make the user's experience of a website quicker and more satisfactory.

For our task this week we looked at using Javascript to take and process simple user inputs, which direct users to certain pages on the BBC website, according to the preferences they stated.

This activity was very challenging; as our lecture notes explain, programming languages can be very unforgiving. It only takes a small error of syntax, grammar or logic in one part of the programme for the whole thing to stop working - which can be frustrating! [URL: https://cityspace0.city.ac.uk/webct/urw/lc20804.tp0/cobaltMainFrame.dowebct?JSESSIONID=BB01LyQJyLY11pW3lL1xGdRprG0wZRKjYvwXJj14m2n284fDpSZt!1034102646!csp0ndg.city.ac.uk!80!-1!815643302!csp0ndh.city.ac.uk!80!-1]

My first impulse was to use the Javascript 'prompt' command to ask for user input, and use 'parseint' to process it. Then, I could use the 'if.. . then' commands to direct the user according to their choices.

So far so good. But was this really the most elegant way to carry out this task? To me, having a series of prompt boxes popping up seemed a bit clunky, so instead I investigated the use of radio buttons to take user input.

You can see my solution here: http://www.student.city.ac.uk/~abhd820/javascript-example.html. The user simply chooses 'News' or 'Sport', which then causes a different set of radio buttons to appear, depending on which initial choice they've made. Once they've made this second choice, they simply click on the 'Go' button to be taken to the page they need.

Word count for this entry: 285 words.

No comments:

Post a Comment