All subjects · Information Technology · WIT12 3 hour practical exam on web development with HTML, CSS and JavaScript

Page components: slideshows, modal boxes, filters, sorting, pop-ups and tabs

Edexcel IAL Information Technology · WIT12 3 hour practical exam on web development with HTML, CSS and JavaScript

JavaScript, HTML and CSS work together to build interactive components. The specification names seven (spec 9.3.4), and the 20-mark JavaScript question asks you to complete components like these.

Practise this in the app: instant marking and a fix for every mistake. Free, no email needed to start.

Practise this lesson

The pattern behind every component

1. HTML holds the content (all slides, the hidden modal, every tab panel).

2. CSS controls what is visible: a class such as .hidden { display: none; } or .active.

3. JavaScript responds to events by changing classes, styles, src or text.

So most components come down to: find the elements, attach event handlers, and show one thing while hiding the others.

Slideshow

<img id="slide" src="images/a.png" alt="Pool photos">
<p id="caption"></p>
<button id="prev">Previous</button>
<button id="next">Next</button>
const slides = ["images/a.png", "images/b.png", "images/c.png"];
let current = 0;
function showSlide(n) {
  current = (n + slides.length) % slides.length;   // wrap round at both ends
  document.getElementById("slide").src = slides[current];
  document.getElementById("caption").textContent = "Slide " + (current + 1) + " of " + slides.length;
}
document.getElementById("next").addEventListener("click", function () { showSlide(current + 1); });
document.getElementById("prev").addEventListener("click", function () { showSlide(current - 1); });
window.addEventListener("load", function () { showSlide(0); });

Caption after loading, then after three clicks on Next, then after one more click on Previous:

Slide 1 of 3
Slide 1 of 3
Slide 3 of 3

The remainder (%) wraps the index round, so Next on the last slide returns to the first. The load handler shows the first slide when the page opens; forgetting to do that cost marks in 2025.

Modal boxes, modal images and pop-ups

A modal box is a dialog shown on top of the page, with the page dimmed behind it, until the user closes it. A modal image opens a large version of a clicked thumbnail in the same way. A pop-up is a small message or box that appears on an event (a tooltip, a confirmation or a 'subscribe' box).

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 100;
}
.modal.show { display: block; }
const modal = document.getElementById("modal");
document.getElementById("thumb").addEventListener("click", function () {
  document.getElementById("bigImg").src = this.src;   // modal image: copy the clicked picture
  modal.classList.add("show");
});
document.getElementById("close").addEventListener("click", function () {
  modal.classList.remove("show");
});

Filter lists, sort lists and tabbed content

// filter: hide list items that do not contain the search text
document.getElementById("search").addEventListener("keyup", function () {
  const term = this.value.toLowerCase();
  document.querySelectorAll("#classes li").forEach(function (li) {
    li.style.display = li.textContent.toLowerCase().includes(term) ? "" : "none";
  });
});
// sort: read the items into an array, sort it, write them back
function sortList() {
  const list = document.getElementById("classes");
  const items = Array.from(list.children).map(li => li.textContent);
  items.sort();
  list.innerHTML = "";
  items.forEach(function (t) {
    const li = document.createElement("li");
    li.textContent = t;
    list.appendChild(li);
  });
}
// tabs: show the chosen panel, hide the rest
function openTab(id) {
  document.querySelectorAll(".panel").forEach(p => p.classList.add("hidden"));
  document.getElementById(id).classList.remove("hidden");
}

The filter uses keyup so the list updates as the user types. Tabs hide every panel and then show one, which guarantees only one is visible; Pearson's 2025 report noted few candidates made sure only one button showed at a time.

Worked example

A page has three tab buttons and three panels with class panel and ids info, prices and times. Explain how openTab("prices") makes only the prices panel visible.

  1. querySelectorAll(".panel") finds all three panels; the loop adds the class hidden to each, so all are hidden.
  2. getElementById("prices") finds one panel and removes its hidden class.
  3. The CSS rule .hidden { display: none; } does the hiding, so only prices is shown.

Answer: Hide every panel first, then show the chosen one.

Key idea: Components combine HTML content, CSS classes that show or hide, and JavaScript event handlers. Slideshows change an index and src (use % to wrap), modals toggle a fixed overlay, filters hide non-matching items on keyup, sorts rebuild a list from a sorted array, tabs hide all panels then show one.

Check yourself

  1. The slideshow code runs and the page loads, then the user clicks Previous once. What does the caption show? ```js const slides = ["images/a.png", "images/b.png", "images/c.png"]; let current = 0; function showSlide(n) { current = (n + slides.length) % slides.length; // wrap round at both ends document.getElementById("slide").src = slides[current]; document.getElementById("caption").textContent = "Slide " + (current + 1) + " of " + slides.length; } document.getElementById("next").addEventListener("click", function () { showSlide(current + 1); }); document.getElementById("prev").addEventListener("click", function () { showSlide(current - 1); }); window.addEventListener("load", function () { showSlide(0); }); ```
    Show answer

    Slide 3 of 3. Starting at slide 1, Previous wraps round to the last slide, so the caption is Slide 3 of 3.

  2. What is displayed when this code runs? ```js const n = 4; let i = 3; i = (i + 1) % n; console.log(i); ```
    Show answer

    0. (3 + 1) % 4 = 0, so the index wraps back to the first item: 0.

  3. Which CSS makes a modal box cover the whole window and stay in place when the page scrolls?
    • position: static; width: 100%;
    • float: left; width: 100%;
    • position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    • position: relative; top: 100%;
    Show answer

    position: fixed; top: 0; left: 0; width: 100%; height: 100%;. A fixed element covering the full width and height of the window overlays the whole page.

  4. What is the usual way for JavaScript to hide or show a component such as a modal box?
    • Delete the HTML file
    • Add or remove a CSS class that sets display: none or display: block
    • Reload the page
    • Change the doctype
    Show answer

    Add or remove a CSS class that sets display: none or display: block. Toggling a class keeps the styling in the CSS and is easy to reverse.

  5. A filter list should update as the user types each letter into the search box. Which event should the handler use?
    • load
    • submit
    • dblclick
    • keyup
    Show answer

    keyup. keyup fires after every key, once the box's value has changed.

  6. What is displayed when this code runs? ```js const items = ["Yoga", "boxing", "Aqua", "Spin"]; items.sort(); console.log(items.join(" ")); ```
    Show answer

    Aqua Spin Yoga boxing. sort() compares character codes, so capitals come before lower case: Aqua Spin Yoga boxing. Use localeCompare or toLowerCase to sort ignoring case.

  7. Why does an openTab function hide every panel before showing the chosen one?
    • Because classList cannot remove classes
    • To make the page load faster
    • Because panels must be deleted first
    • So only one panel is ever visible, whichever was open before
    Show answer

    So only one panel is ever visible, whichever was open before. Hiding all first guarantees exactly one visible panel.

Practise with instant feedback

Sources

Last updated 8 November 2026. Spotted a mistake? Tell us.