CHAPTER 59 · HTML
Final project: a form with a working practice result page
Build a labelled form and read its submitted values. See the complete browser-side journey without pretending to build a booking or message service.
Download example files (ZIP)The problem we will solve
Plan both sides before writing
Choose understandable fields
Follow a sample submission
Read the result script slowly
What the result page proves
Test normal, missing and unusual values
Extend only after the small version works
Follow the idea
- 1Enter fictional values
- 2GET adds named URL entries
- 3Read the result query
- 4Display plain text
Displaying values does not send a message or save a record.
Complete program: project-question.html
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Practice Question Form</title>
</head>
<body>
<h1>Prepare a fictional study question</h1>
<main>
<p>
This local exercise displays values in the next page. It does not contact a teacher or save
a request. Use made-up details; GET values appear in the URL.
</p>
<form action="project-question-result.html" method="get">
<p>
<label for="question-alias">Practice alias (required, up to 30 characters)</label>
<input id="question-alias" name="alias" type="text" required maxlength="30" />
</p>
<p>
<label for="question-topic">Topic (required)</label>
<select id="question-topic" name="topic" required>
<option value="">Choose a topic</option>
<option value="links">Links</option>
<option value="forms">Forms</option>
</select>
</p>
<p><label for="question-text">Practice question (required, up to 200 characters)</label></p>
<p>
<textarea
id="question-text"
name="question"
rows="4"
cols="28"
required
maxlength="200"
></textarea>
</p>
<button type="submit">Display practice values</button>
</form>
</main>
</body>
</html>This preview shows the example in a browser. Save the complete code in local files to test links between pages and downloads. Same-page section links work here. Form submission is disabled in this preview. Save the example and its result page locally to test submission. Use fictional practice values.
Complete program: project-question-result.html
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Practice Question Result</title>
</head>
<body>
<h1>Read your practice values</h1>
<main>
<p>
This page reads its URL. Nothing was booked, sent to a teacher or stored in a database.
Anyone can change these URL values.
</p>
<dl>
<dt>Practice alias</dt>
<dd id="result-alias">Not provided</dd>
<dt>Topic</dt>
<dd id="result-topic">Not provided</dd>
<dt>Question</dt>
<dd id="result-question">Not provided</dd>
</dl>
<p><a href="project-question.html">Return to the practice form</a></p>
<script>
const values = new URLSearchParams(window.location.search);
document.getElementById('result-alias').textContent = values.get('alias') || 'Not provided';
document.getElementById('result-topic').textContent = values.get('topic') || 'Not provided';
document.getElementById('result-question').textContent =
values.get('question') || 'Not provided';
</script>
</main>
</body>
</html>This preview shows the example in a browser. Save the complete code in local files to test links between pages and downloads. Same-page section links work here. JavaScript does not run in this preview. Save the complete example and any named script file together to test its actions or canvas drawing in your browser.
Problem and solution
Common mistakes and useful tips
Names in the script must match form names, not just ids. Use plain text insertion for answers. Do not collect secrets with GET. A display page is not trusted server validation. Opening a static page is not proof of sending or saving.
Practice questions
What must action match? Which attribute identifies the submitted alias key? What does URLSearchParams.get return when a key is absent? Why use textContent? Does changing the URL prove the visitor is authorised? Add a count field and describe every matching change.
Check your practice answers
The actual result filename and path: project-question-result.html in this exercise. Name=alias. Id connects the label and control. Null. The example displays Not provided through the fallback expression. It displays the answer as plain text rather than interpreting supplied markup. No. URL values are editable; this exercise does not authenticate anyone. Add its label, unique id and name to the form; add a result destination; read that name with get and insert its value as text with a missing-value fallback.
Interview questions
How does a GET form reach this result page?
Is browser validation enough for a real service?
Why is a static success page misleading?
Does textContent solve every security problem?
Quick revision
Match labels, names and result destinations. GET exposes values in the URL. Read the query and insert plain text. Display is different from sending or storing.