Revision Notes
Cambridge A Level Information Technology (ICT): Programming for the web (9626) – Revision Notes
Revision notes for Cambridge A Level IT 9626 Programming for the web: JavaScript syntax tables, events, popups, loops, timers and a quick self-test.
- Subject
- ICT
- Level
- A LEVEL
- Topic
- Programming for the web
- Author
- Marlbridge Academic Team
- Updated
Aligned to Cambridge A Level Information Technology (9626), 2025-2027. Official specification .
Syllabus page (what it covers and how it is assessed): Cambridge A Level Information Technology.
Syllabus points this page covers
9626 (A Level)
- 21 Programming for the web (whole topic)
Found an error? Report a correction.
Need help with this topic? Request a free trial class for A Level Information Technology (9626).
These revision notes cover topic 21, Programming for the web, of Cambridge International AS & A Level Information Technology (9626), following the syllabus for examination in 2025, 2026 and 2027 (version 3), section 21.1. Topic 21 is A Level only. Paper 3 (Advanced Theory) questions are based on sections 12–21 and Paper 4 (Advanced Practical) tasks on sections 17–21, so expect JavaScript in both. For full explanations and worked examples, use the Programming for the web study guide.
Course hub: Cambridge A Level ICT. Checklist: 9626 checklist. Test yourself with the Programming for the web practice questions, and find your weak spots with a free 10-minute diagnostic. Pseudocode versions of loops and selection are in the Algorithms and flowcharts revision notes.
Topic 21 at a glance
| Area of 21.1 | Key items |
|---|---|
| Adding interactivity | <script> in HTML; external .js file via src |
| Changing content | innerHTML, calculations, string methods, image src/width/alt |
| Changing styles | document.getElementById(id).style.property = new style |
| Show/hide | style.visibility, style.display |
| Displaying data | innerHTML, document.write(), window.alert(), console.log() |
| Events | onload, onchange, onclick, onmouseover, onmouseout, onkeydown |
| Popups | alert(), confirm(), prompt() |
| Syntax | values, operators, comparisons, expressions, keywords, comments |
| Control | if, else, else if, switch, ternary, for, for/in, while, do/while, break |
| Functions and timing | event, invoked, self-invoked; setTimeout(), setInterval() |
| Data | number, string, Boolean, array, object; type conversions |
Definitions
- Statement: one instruction, ended with
;. - Literal: a fixed value written in the code, such as
7,"Lahore",false. - Variable: a named store whose value can change. Declared with
let,constorvar. - Expression: values and operators that work out to one value, such as
price * qty. - Keyword: a reserved word with a set meaning (
if,for,function,return,break). - Comment: text the browser ignores:
//to the end of the line, or/* ... */over several lines. - Array: an ordered list in square brackets; the first index is 0.
- Object: named properties in curly brackets, such as
{town: "Multan", pop: 2}. - Function: a named block of code that runs only when executed.
- Event: something that happens to an HTML element, which can trigger code.
Adding JavaScript to a page
| Method | How | Good for |
|---|---|---|
| Inline script | Code between <script> and </script> in the <head> or <body> |
Short code used by one page |
| External script | <script src="file.js"></script>; the .js file has no <script> tags |
Code shared by many pages; one edit updates all; file can be cached |
Method in steps – change content, images and styles
- Find the element:
document.getElementById("id"). The id is a string in quotes and must match the HTML exactly. - Text or numbers: set
.innerHTMLto the new value or expression. - Images: set
.srcto the new file name;.width,.heightand.altchange in the same way. - Styles: set
.style.property; hyphenated CSS names become camelCase (font-size→fontSize,background-color→backgroundColor). - Style values are strings with units where needed:
"18px","blue","#ff0000".
Output methods compared
| Method | Output appears | Watch out |
|---|---|---|
innerHTML |
Inside a chosen element | Element needs an id |
document.write() |
In the HTML output | After loading, it clears the page |
window.alert() |
Popup the user must close | Interrupts the user |
console.log() |
Browser console only | Users do not see it |
Show and hide
| Code | Hidden? | Space kept? |
|---|---|---|
style.visibility = "hidden" |
Yes | Yes |
style.display = "none" |
Yes | No |
style.visibility = "visible" / style.display = "block" |
No (shown) | – |
Events
| Event | Fires when |
|---|---|
onload |
page or image finishes loading |
onchange |
value changes; a text box fires when it loses focus |
onclick |
element clicked |
onmouseover / onmouseout |
pointer enters / leaves the element |
onkeydown |
a key is pressed |
Popups – return values
| Popup | Buttons | Returns |
|---|---|---|
alert(msg) |
OK | nothing useful |
confirm(msg) |
OK, Cancel | true / false |
prompt(msg, default) |
OK, Cancel | the typed string, "" if empty, null on Cancel |
Operators
| Group | Operators |
|---|---|
| Assignment | = += -= *= /= |
| Arithmetic | + - * / % ** ++ -- |
| String | + += (join) |
| Comparison | == === != !== > < >= <= |
| Logical | && AND, ` |
| Ternary | condition ? a : b |
| Type | typeof x |
Order of working: brackets, then **, then * / %, then + -.
Comparison results with x = 6:
| Expression | Result | Why |
|---|---|---|
x == "6" |
true |
same value |
x === "6" |
false |
different type |
x != "6" |
false |
same value |
x !== "6" |
true |
different type |
x >= 6 && x < 10 |
true |
both parts true |
x > 8 || x === 6 |
true |
one part true |
!(x > 2) |
false |
NOT reverses true |
Data types and conversions
| Want | Use | Example → result |
|---|---|---|
| String to number | Number() |
Number("7.5") → 7.5 |
| Whole number from text | parseInt() |
parseInt("45.8") → 45 |
| Decimal from text | parseFloat() |
parseFloat("2.5m") → 2.5 |
| Number to string | String() / .toString() |
String(9) → "9" |
| Fixed decimals (gives string) | .toFixed(n) |
(2).toFixed(2) → "2.00" |
| Check type | typeof |
typeof "true" → "string" |
+ with any string joins: "4" + "4" → "44". Other arithmetic converts: "9" / "3" → 3. Text that is not a number becomes NaN; test with isNaN().
Method in steps – read, calculate, display
- Give each HTML element an
id. - Read input:
let v = document.getElementById("box").value; - Convert:
v = Number(v); - Validate:
if (isNaN(v)) { ... } - Calculate in an expression.
- Output:
document.getElementById("out").innerHTML = result; - Attach the function to an event, such as
onclickoronchange.
Method in steps – timers
- Write the function to repeat.
- Start it:
let id = setInterval(tick, 1000);(milliseconds). - Inside
tick, change the counter and update the page. - Stop with
clearInterval(id)when the end condition is met. - For a single delayed action, use
setTimeout(fn, ms)instead.
Loops
| Loop | Tests | Runs at least once? | Best for |
|---|---|---|---|
for |
before each pass | No | known number of passes, array indexes |
for/in |
– | No | each property of an object |
while |
before each pass | No | unknown number of passes |
do/while |
after each pass | Yes | input that must be asked for at least once |
break leaves the loop (or a switch) at once.
Functions – three ways to run
| Way | Example | Runs when |
|---|---|---|
| On an event | <button onclick="check()"> |
The user clicks |
| Invoked from code | let v = area(4, 5); |
That line is reached |
| Self-invoked | (function () { ... })(); |
As soon as it is read |
Small worked reminders
let s = "Lahore";givess.charAt(2)→"h"ands.indexOf("o")→3. Positions start at 0.let m = [4, 8, 6];givesm.length→3andm[1]→8.for (let k in {a: 1, b: 2})visits the property namesathenb.setTimeout(show, 2500)runsshowonce, 2.5 seconds later.- Fall-through: with
g = 2,switch (g) { case 2: out += "B"; case 3: out += "C"; break; default: out += "X"; }leavesoutas"BC", because case 2 has nobreak.
Must-know distinctions
==compares value only;===compares value and type.=assigns;===compares.visibility = "hidden"keeps the space;display = "none"removes it.setTimeoutruns once;setIntervalrepeats.whiletests first;do/whiletests last.if/else iftests different conditions;switchmatches one value against cases.- Inline
<script>is in the HTML file; an external script is a separate.jsfile linked withsrc. - A function run by an event waits for the user; a self-invoked function runs as soon as it is read.
Quick self-test
- What does
"4" + "4"give? - What does
"9" / "3"give? - What is
10 % 4? - Is
3 === "3"true or false? - What does
typeof "true"give? - What does
parseInt("45.8")give? - After
let k = 0; for (let i = 0; i < 4; i++) { k += i; }, what isk? - With
let t = 28;, what doest > 25 ? "Hot" : "Mild"give? - After
let y = 0; do { y += 5; } while (y < 12);, what isy? - With
let w = "Marlbridge";, givew.lengthandw.substring(0, 4). - What does
prompt()return when Cancel is clicked? - Write a statement that removes the element with id
menufrom the layout.
Answers
"44"(a string).3(a number).2.- False: same value, different type.
"string".45.6(0 + 1 + 2 + 3)."Hot".15(5, 10, 15; the test fails at 15).10and"Marl".null.document.getElementById("menu").style.display = "none";
Where marks are usually lost
- Writing
getElementByID; JavaScript is case-sensitive, so it fails. - Forgetting quotes round style values or leaving out units (
"20px"). - Adding text-box values without converting, so
"2" + "3"gives"23". - Saying
visibilityanddisplay“do the same thing” without the layout difference. - Describing
console.log()as showing output to the user. - Mixing up
setTimeout(once) andsetInterval(repeating), or giving times in seconds instead of milliseconds. - Missing
breakinswitch, so later cases also run. - Tracing a
do/whileas if it tests first. - Testing
prompt()input for""but notnull. - Naming an event without saying which element it is attached to or what it triggers.
Official syllabus
Cambridge International AS & A Level Information Technology 9626, syllabus for examination in 2025, 2026 and 2027, version 3, Cambridge University Press & Assessment. Topic 21: Programming for the web (21.1 Programming for the web).
Get free revision emails (optional)
Occasional emails with practice questions, worked explanations and links to free resources for the qualification and subjects you choose. No spam, and you can unsubscribe from any email. The free tools on this site never need an email.
Related resources
-
Study guides
Cambridge A Level Information Technology (ICT): Programming for the web (9626)
Study guide for Cambridge A Level IT 9626 Programming for the web: JavaScript in HTML, events, output, data types, operators, loops and timers.
ICT · Cambridge · A Level
Read guide -
Practice questions
Cambridge A Level Information Technology (ICT): Programming for the web (9626) – Practice Questions
Original practice questions with worked answers for Cambridge A Level IT 9626 Programming for the web, from tracing JavaScript to writing timers.
ICT · Cambridge · A Level
Try questions -
Study guides
Cambridge A Level Information Technology (ICT): Project management (9626)
Study guide to project management for Cambridge A Level IT 9626: the project life cycle, project software, Gantt charts, PERT and critical path.
ICT · Cambridge · A Level
Read guide
Related articles
-
teaching
A Level tuition in Dubai: Cambridge or Pearson Edexcel International A Level?
Schools in Dubai and Abu Dhabi teach either Cambridge International AS & A Level or Pearson Edexcel International A Level. How the two are structured, why it matters for tuition, and how online classes from Lahore work.
9 October 2026
-
curriculum guides
Choosing subjects at IGCSE and A Level
How subject choices at 14 and 16 affect university options later, and how to keep pathways open without overloading a timetable.
28 July 2026
Studying this with a teacher
Working through ICT A LEVEL?
This page is free and stays free. If you would rather be taught it, Marlbridge runs ICT classes one-to-one and in small groups of up to 15, online in your own time zone. The first trial class is free. WhatsApp replies within an hour (8am–11pm Pakistan time, every day); email the same day.
Cambridge ICT teachers at Marlbridge