Programming for the web – A Level Information Technology (9626)
Quick quiz: 10 random questions from this topic. Answer them all, then open the Summary.
Question text
19
Explain, with reference to the code shown, how the JavaScript collects the dimensions of the
rectangle, calculates the area and displays the area on-screen.
The lines of the code are numbered only for your convenience when referring to the code.
…
…
…
…
…
…
…
…
…
…
…
…
…
… [6]
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
publisher will be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge
Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download
at www.cambridgeinternational.org after the live examination series.
Cambridge Assessment International Education is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of the University of
Question text
1
JavaScript uses loops to execute a block of code using Iterative methods.
(a) Describe what is meant by an Iterative method.
…
…
…
…
…
… [2]
(b) Explain how a do/while loop differs from a while loop.
…
…
…
…
…
… [2]
(c) Explain why a while loop might be used instead of a for loop in JavaScript code.
…
…
… [1]
Question text
10 JavaScript code can be executed when an HTML event happens in a web browser. An example of
an HTML event is when a user clicks a mouse button.
(a) Describe how the JavaScript in this HTML code changes the display of text on the web page
when a mouse button is clicked.
The line numbers are included for reference only.
1
<html>
2
<body>
3
4
<h2>Cambridge International JS Code: HTML Event</h2>
5
<h2 onclick="changeText(this)">Click on this line to see the name
of this 9626 QP</h2>
6
7
<script>
8
function changeText(id) {
9
id.innerHTML = "A Level IT Paper 3";
10
}
11
</script>
12
13 </body>
14 </html>
…
…
…
…
…
…
…
…
…
… [4]
(b) Describe two other HTML events that can be used to trigger the execution of JavaScript
code.
…
…
…
…
…
… [2]
ĬÛú¾Ġ´íÈõÏĪÅĊàü·þ×
Question text
1
Data that is output from JavaScript code is passed to HTML so that a web browser can display it.
A web page displays the name of a question paper in a web browser. The emboldened title of the
page is created by HTML code, but the name of the question paper is output by JavaScript code
and is displayed.
File
C:/9626.html
This code displays the question paper name in a web browser
Paper 3 Advanced Theory 9626/32
The web page code is shown. The line numbers are only for reference.
1
<html>
2
<body>
3
<h2>This code displays the question paper name in a web browser</h2>
4
<br>
5
<br>
6
<p id="QPname"></p>
7
8
<script>
9
var a = "9626/32";
10
var b = "Paper 3 Advanced Theory";
11
document.getElementById("QPname").innerHTML = b + " " + a;
12
</script>
13
14
</body>
15
</html>
© Cambridge University Press & Assessment 2026
,
,
Describe how the code processes and passes the name of the question paper to the web
browser for display.
…
…
…
…
…
…
…
…
…
…
…
…
…
… [6]
© Cambridge University Press & Assessment 2026
Question text
9
JavaScript is a programming language used in webpages.
Fig. 2 shows a table created with JavaScript in a webpage.
1
2
3
4
5
6
7
8
9
10
2
4
6
8
10
12
14
16
18
20
3
6
9
12
15
18
21
24
27
30
4
8
12
16
20
24
28
32
36
40
5
10
15
20
25
30
35
40
45
50
6
12
18
24
30
36
42
48
54
60
7
14
21
28
35
42
49
56
63
70
8
16
24
32
40
48
56
64
72
80
9
18
27
36
45
54
63
72
81
90
10
20
30
40
50
60
70
80
90
100
Fig. 2
The code that created the table is shown below:
<html>
<body>
<script language="javascript">
var tableout;
tableout = "<table border='1' width='300' cellspacing='0'
cellpadding='3'>"
for (b = 1; b <= 10; b++) {
tableout = tableout + "<tr>";
for (g = 1; g <= 10; g++) {
tableout = tableout + "<td>" + b * g + "</td>";
}
tableout = tableout + "</tr>";
}
tableout = tableout + "</table>";
document.write (tableout);
</script>
</body>
</html>
Explain how the loops in the code create the table.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
Question text
7
The table shows part of a database used to control the level of stock items in a clothing store.
Reordering is done when the number left in stock reaches or falls below the minimum level allowed
by the store management.
Item_Code Description_of_Item Item_Price Current_Stock_ Minimum_Stock_ Quantity_to-be_
Level
Level_Allowed
Reordered
XYP234
Walking boots (pair)
$128.50
16
15
10
ABG765
Jackets
$99.56
15
10
15
SCC653
Gloves (pair)
$36.99
23
20
25
SOX785
Socks (pair)
$25.99
33
30
50
XYT981
Scarf
$34.45
16
10
20
A customer purchases two pairs of walking boots, three pairs of socks and a scarf. The items each
have a barcode and are scanned at the checkout when purchased.
Describe, in detail, the processes that would occur when the purchases have been made to ensure
that the appropriate new orders are placed to maintain the stock levels.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
… [8]
Question text
9
A programmer is writing some JavaScript code to display this text on a web page:
This is “Cambridge International IT 9626 Paper 3”
The programmer uses strings in the code.
(a) Describe the purpose of strings in JavaScript.
…
…
… [1]
(b) The programmer’s first attempt at the HTML and JavaScript code is shown in Fig. 9.1. Line
numbers are shown only for your use when referring to the code.
1
<!DOCTYPE html>
2
<html>
3
<body>
4
5
<h2>This is "Cambridge Assessment International Education"</h2>
6
7
<p id="string"></p>
8
9
<script>
10
var x = "This is "Cambridge International IT 9626 Paper 3"";
11
document.getElementById("string").innerHTML = x;
12
</script>
13
14
</body>
15
</html>
Fig. 9.1
When run in a web browser the HTML code outputs the heading in line 5 on the page. The browser
executes the JavaScript code shown in lines 9 to 12.
The expected output of the code on the web page is shown in Fig. 9.2 but the actual output is
shown in Fig. 9.3.
Fig. 9.2
Fig. 9.3
Explain why the error in line 10 prevents the JavaScript code from outputting:
This is “Cambridge International IT 9626 Paper 3”
…
…
…
…
…
…
…
…
…
…
… [4]
(c) JavaScript programmers often wish to control when sections of their code are executed.
Compare the use of setTimeout() and setInterval() for delaying the execution of
JavaScript code.
…
…
…
…
Question text
2
QR codes are two-dimensional bar codes (matrix bar codes) representing information about items
to which they are attached. An example of a QR code is shown:
(a) Describe the functional elements of a QR code.
…
…
…
…
…
…
…
…
…
…
… [5]
(b) Explain why damaged QR codes may still be read while damaged one-dimensional bar codes
often cannot be read.
…
…
…
…
…
…
… [3]
Question text
4
JavaScript code has been developed for an interactive website. White box testing is carried out by
the developers.
(a) Describe how white box testing is used to test the code.
…
…
…
…
…
…
…
…
…
…
…
…
…
… [6]
(b) Describe one way that JavaScript code can add interactivity to a web page.
…
…
…
… [1]
(c) HTML events occur when users interact with a web page.
Describe how JavaScript code can be made to react to an HTML event.
…
…
…
…
…
…
…
Question text
1
JavaScript can be used in a web-based form to test whether a number entered by a user matches
a certain condition and to select and output an appropriate message.
(a) Explain how if...else statements are used to do this.
…
…
…
…
…
…
…
…
…
… [4]
(b) The ternary operator could be used instead of if...else.
Explain why the ternary operator could be used to do this.
…
…
…
…
…
…
…
… [3]