Software EngineeringAlliance Girls High School
TERM 3 / LESSON 05

HOLIDAY SELF-STUDY · WEEK 1

Website Interactivity

HOLIDAY SELF-STUDY · WEEK 1 · TUTORIAL

Build a search box.
Step by step.

Practise in a new NitroIDE project first, then add one interaction to your own capstone.

  • TimeAbout 2–3 hours. Stop after any step and continue later.
  • ToolNitroIDE in your browser. No account needed.
  • GoalOne working interaction in your capstone.

Do each numbered step, compare with ✅ Check, then press → for the next slide. Written guide: Lesson 5 · Holiday Self-Study Pack.

01

STEP 1 OF 11 · SET UP

Back up, then start fresh.

  1. Open NitroIDE and your capstone project.
  2. Click Prefs → Download ZIP. Keep the file somewhere safe.
  3. Click Projects → New Project.
  4. Delete the starter code in index.html, style.css and script.js.

✅ Check: three empty files and a blank preview. Your capstone is untouched.

You will return to your capstone in Step 8.

02

STEP 2 OF 11 · INDEX.HTML

Add the HTML.

  1. Click index.html.
  2. Type the code exactly as shown.
  3. Look at the preview on the right.

index.html

<label for="search">Find a resource</label>
<input id="search" type="search">
<button id="search-button" type="button">Search</button>
<button id="reset" type="button">Reset</button>
<p id="status" aria-live="polite"></p>
<ul id="results"></ul>

✅ Check: a label, a search box, a Search button and a Reset button. Clicking does nothing yet.

Each id is a name JavaScript will use to find that element.

03

STEP 3 OF 11 · SCRIPT.JS

Store data. Find elements.

  1. Click script.js.
  2. Type the array of resources.
  3. Type the five querySelector lines.
  4. Open the Console tab under the preview.

script.js

const resources = [
  { title: "Revision group" },
  { title: "Science fair" },
  { title: "Coding club" }
];

const searchInput = document.querySelector("#search");
const searchButton = document.querySelector("#search-button");
const resetButton = document.querySelector("#reset");
const status = document.querySelector("#status");
const results = document.querySelector("#results");

✅ Check: the page has not changed and the Console shows no red errors.

Each "#name" must match an id in index.html exactly.

04

STEP 4 OF 11 · SCRIPT.JS · ADD BELOW

Show the results.

  1. Add this function below your Step 3 code.
  2. The last line runs it once with every resource.
  3. Watch the preview.

script.js · add at the bottom

function showResults(items) {
  results.replaceChildren();
  for (const item of items) {
    const listItem = document.createElement("li");
    listItem.textContent = item.title;
    results.append(listItem);
  }
  if (items.length === 0) {
    status.textContent = "No resources match your search.";
  } else {
    status.textContent = `${items.length} result(s) found.`;
  }
}

showResults(resources);

✅ Check: three resources in a list and 3 result(s) found.

textContent shows text safely. Never put user text into innerHTML.

05

STEP 5 OF 11 · SCRIPT.JS · ADD BELOW

Make Search work.

  1. Add this code at the bottom.
  2. Type club in the search box.
  3. Click Search.

script.js · add at the bottom

function searchResources() {
  const query = searchInput.value.trim().toLowerCase();
  const matches = resources.filter((item) =>
    item.title.toLowerCase().includes(query)
  );
  showResults(matches);
}

searchButton.addEventListener("click", searchResources);

✅ Check: only “Coding club” is listed and the status says 1 result(s) found.

Event = click. Action = filter the array. Feedback = the new list and status message.

06

STEP 6 OF 11 · SCRIPT.JS · ADD BELOW

Add Enter and Reset.

  1. Add this code at the bottom.
  2. Type xyz and press Enter.
  3. Click Reset.

script.js · add at the bottom

searchInput.addEventListener("keydown", (event) => {
  if (event.key === "Enter") {
    searchResources();
  }
});

resetButton.addEventListener("click", () => {
  searchInput.value = "";
  showResults(resources);
  searchInput.focus();
});

✅ Check: “No resources match your search.” appears, then Reset brings back all three resources.

07

STEP 7 OF 11 · TEST

Add data. Test with a keyboard.

  1. Add { title: "Debate club" } to the array. Put a comma after the item before it.
  2. Search for club.
  3. Click inside the preview. Use only Tab, Enter and Space to search and reset.
  4. Click Prefs → Download ZIP to save your practice.

✅ Check: 2 result(s) found. and everything works without a mouse.

08

STUCK? · COMMON FIXES

Read the red error.

  • Nothing happens on clickCheck the id in index.html matches the "#name" in script.js exactly.
  • “… is not defined”A name is spelled differently. Capital letters matter: searchInput ≠ searchinput.
  • “Cannot read properties of null”querySelector found nothing. Fix the id spelling.
  • “Unexpected token”A bracket, quote or comma is missing. Compare line by line with the slide.

The Console shows the line number of the first error. Fix that one first.

09

STEP 8 OF 11 · YOUR CAPSTONE

Plan your interaction.

  1. Click Projects and open your capstone. Click Download ZIP first as a backup.
  2. Opportunities Hub: add a search box or category buttons. Reuse Steps 2–6 with your opportunities array.
  3. Weather Dashboard: add one button per town. On click, show that town’s name in a status message.
  4. CyberSmart Quest: add one button per answer. On click, show “Correct!” or “Try again” and an explanation.

✅ Check: you know which elements to add and what the feedback message will say.

10

STEP 9 OF 11 · YOUR CAPSTONE

Build it in your project.

  1. Add the HTML elements with labels and unique ids.
  2. Select them in script.js with querySelector.
  3. Write one function for the action.
  4. Connect it with addEventListener.
  5. Show a status message, including when nothing matches.

pattern to copy and change

const button = document.querySelector("#my-button");
const status = document.querySelector("#status");

function handleClick() {
  // 1. Read your data or the user's choice
  // 2. Decide what to show
  status.textContent = "Tell the user what happened.";
}

button.addEventListener("click", handleClick);

✅ Check: it works with mouse and keyboard, shows a status message and handles “nothing found”.

11

STEP 10 OF 11 · HOME TEST

Watch someone try it.

  1. Ask a family member or friend to do one task, such as “Find a coding opportunity”.
  2. Do not explain or point. Just watch.
  3. Write down where they hesitate or get stuck.
  4. Fix one thing, then click Download ZIP.

✅ Check: you made one improvement because of what you saw.

12

STEP 11 OF 11 · SAVE + JOURNAL

Save it. Write it down.

  1. Click Download ZIP and copy it to a flash disk, email or cloud drive.
  2. In your journal, write one line each: the event, the action and the feedback of your feature.
  3. Write the one thing your tester changed.

✅ Check: your capstone has one working interaction, your ZIP is saved and your journal is done.

Next: Lesson 6 — fetch live data →

13
01/13

← → to navigate · F fullscreen

Slide 1 of 13