Unit 1: Web page and script development
Web Technologies Laboratory notes · PTU syllabus (PGCA1914)
On this page
- Unit summary
- Book index, tag demonstration and timetable
- Scrolling letterhead and in-page navigation
- Audio, video and split-pane layouts
- Employee bio-data page
- Styling with CSS: the hospital front page
- Displaying two web pages together
- Login and registration forms with validation
- College website with tutorial links
- JavaScript programs: arithmetic, quadratic and greatest of three
- Average and grade computation
- Scientific calculator
- Even–odd, prime, table, factorial and Fibonacci
- Key terms
- Quick revision
- Important questions
Unit summary
This lab builds web pages and scripts: a book index, tag demonstrations, a scrolling college letterhead, in-page navigation, formatted text, timetables and table layouts, audio and video, split-pane layouts, a bio-data page, a styled hospital front page, JavaScript login and registration forms, a college website, and scripts for arithmetic, quadratic equations, the greatest of three numbers, grades, a scientific calculator, even–odd and prime checks, tables, factorials and Fibonacci series.
After this unit you can
- Build pages with formatting, lists, tables, links and media
- Lay out and style pages with CSS
- Validate login and registration forms with JavaScript
- Write JavaScript programs for calculations and series
PTU syllabus topics
- Book index page design
- simple HTML tag demonstration
- scrolling college letterhead
- in-page hyperlink navigation
- university name text formatting
- department timetable
- table-based layout
- embedding audio/video
- split-pane page layout with logos
- employee bio-data
- hospital front page styling
- dual web page display
- JavaScript-driven login and registration forms
- college/department website with tutorial links
- arithmetic operation scripts
- quadratic equation solver
- greatest-of-three script
- average and grade computation script
- scientific calculator
- even/odd and prime checks
- multiplication table
- factorial and Fibonacci series scripts
- 1
Plan pages
Home, departments, tutorials
- 2
Create the HTML structure
- 3
Style with CSS
- 4
Add navigation links
- 5
Add forms with JavaScript validation
- 6
Test in multiple browsers
Topic 1
Book index, tag demonstration and timetable
| Exercise | Key tags |
|---|---|
| Book index page | <ol>, nested lists, <a> links to chapters |
| College letterhead | <h1>, <img>, <hr>, <address>, CSS for layout |
| In-page navigation | id attributes and <a href="#section"> |
| Formatted letter | <p>, <b>, <i>, <u>, <br>, alignment |
| Department timetable | <table>, <th>, colspan, rowspan, <caption> |
| Student bio-data | Table or definition list with photo |
Topic 2
Scrolling letterhead and in-page navigation
html<!-- Scrolling college letterhead (CSS animation replaces the obsolete marquee tag) -->
<style>
.ticker { overflow: hidden; white-space: nowrap; background: #1e3a8a; color: #fff; }
.ticker span { display: inline-block; padding-left: 100%; animation: scroll 12s linear infinite; }
@keyframes scroll { to { transform: translateX(-100%); } }
</style>
<div class="ticker"><span>Synetic Business School, Ludhiana — Affiliated to I.K. Gujral Punjab Technical University</span></div>
<!-- In-page navigation with fragment links -->
<nav><a href="#about">About</a> | <a href="#courses">Courses</a> | <a href="#contact">Contact</a></nav>
<h2 id="about">About</h2> ...
<h2 id="courses">Courses</h2> ...
<h2 id="contact">Contact</h2> ... <a href="#top">Back to top</a>Topic 3
Audio, video and split-pane layouts
- Audio:
<audio src="song.mp3" controls></audio> - Video:
<video src="tour.mp4" width="480" controls></video> - Multi-frame page: a logo frame at the top, a menu on the left and content on the right — built with
<frameset>in old HTML, or with<iframe>and CSS layout today.
Topic 4
Employee bio-data page
html<table border="1" cellpadding="6" style="border-collapse: collapse">
<caption><b>Bio-Data</b></caption>
<tr><td rowspan="4"><img src="photo.jpg" alt="Photograph" width="110"></td>
<th>Name</th><td>Simran Kaur</td></tr>
<tr><th>Designation</th><td>Assistant Professor</td></tr>
<tr><th>Qualification</th><td>M.Sc IT, UGC-NET</td></tr>
<tr><th>Email</th><td><a href="mailto:simran@example.com">simran@example.com</a></td></tr>
<tr><th colspan="2">Experience</th><td>6 years</td></tr>
</table>Topic 5
Styling with CSS: the hospital front page
html<link rel="stylesheet" href="hospital.css">cssbody { font-family: Arial, sans-serif; margin: 0; }
header { background: #0b6b3a; color: white; padding: 20px; }
nav a { color: white; margin-right: 15px; text-decoration: none; }
.card { border: 1px solid #ddd; border-radius: 8px; padding: 15px; }Topic 6
Displaying two web pages together
html<!-- iframe-based dual display (framesets are obsolete in HTML5) -->
<div style="display:flex; gap:8px; height:90vh">
<iframe src="page1.html" title="Page one" style="flex:1; border:1px solid #ccc"></iframe>
<iframe src="page2.html" title="Page two" style="flex:1; border:1px solid #ccc"></iframe>
</div>Topic 7
Login and registration forms with validation
- 1
Read values
document.forms["reg"]
- 2
Check required fields
Not empty
- 3
Check formats
Email contains @ and a dot; phone has 10 digits
- 4
Check passwords
Length ≥ 8 and both entries match
- 5
Show errors
alert or a message next to the field
- 6
Return true or false
javascriptfunction validateReg() {
const f = document.forms["reg"];
if (!/^[0-9]{10}$/.test(f.phone.value)) { alert("Enter a 10-digit phone"); return false; }
if (f.pwd.value !== f.cpwd.value) { alert("Passwords do not match"); return false; }
return true;
}Exam tip
The final project — an institute website with department pages, tutorial links and validated forms — usually carries the most marks. Keep a consistent navigation bar and one external CSS file for all pages.
Topic 8
College website with tutorial links
- 1
Plan pages
Home, About, Departments, Courses, Tutorials, Contact
- 2
Common header and navigation on every page
- 3
Department pages with faculty tables
- 4
Tutorials page linking to topic pages (HTML, CSS, JavaScript) and external references
- 5
Shared stylesheet style.css
- 6
Test all links and check on mobile width
Topic 9
JavaScript programs: arithmetic, quadratic and greatest of three
html<input id="a" type="number"> <input id="b" type="number"> <input id="c" type="number">
<button onclick="calc()">Run</button> <pre id="out"></pre>
<script>
function calc() {
const a = +document.getElementById("a").value,
b = +document.getElementById("b").value,
c = +document.getElementById("c").value;
let s = `Sum ${a + b}, Difference ${a - b}, Product ${a * b}, Quotient ${b ? (a / b).toFixed(2) : "undefined"}\n`;
s += `Greatest of three: ${Math.max(a, b, c)}\n`;
const d = b * b - 4 * a * c; // treat a, b, c as coefficients
if (a === 0) s += "Not a quadratic equation";
else if (d >= 0) s += `Roots: ${((-b + Math.sqrt(d)) / (2 * a)).toFixed(2)}, ${((-b - Math.sqrt(d)) / (2 * a)).toFixed(2)}`;
else s += `Complex roots: ${(-b / (2 * a)).toFixed(2)} ± ${(Math.sqrt(-d) / (2 * a)).toFixed(2)}i`;
document.getElementById("out").textContent = s;
}
</script>Topic 10
Average and grade computation
javascriptfunction grade(marks) { // marks: array of five subject marks
const avg = marks.reduce((s, m) => s + m, 0) / marks.length;
const g = avg >= 90 ? "O" : avg >= 75 ? "A" : avg >= 60 ? "B" : avg >= 40 ? "C" : "F";
return `Average ${avg.toFixed(1)} — Grade ${g}`;
}
console.log(grade([78, 85, 91, 66, 72])); // Average 78.4 — Grade ATopic 11
Scientific calculator
html<input id="disp" readonly>
<div id="keys"></div>
<script>
const keys = ["7","8","9","/","sin","4","5","6","*","cos","1","2","3","-","tan",
"0",".","(",")","+","sqrt","log","^","C","="];
const disp = document.getElementById("disp");
for (const k of keys) {
const b = document.createElement("button"); b.textContent = k;
b.onclick = () => {
if (k === "C") disp.value = "";
else if (k === "=") {
try {
const expr = disp.value.replace(/sin|cos|tan|sqrt|log/g, f => "Math." + (f === "log" ? "log10" : f))
.replace(/\^/g, "**");
if (!/^[0-9+\-*/().\s Mathsincotaqrlg]*$/.test(expr)) throw "bad";
disp.value = Function(`"use strict"; return (${expr})`)();
} catch { disp.value = "Error"; }
} else disp.value += ["sin","cos","tan","sqrt","log"].includes(k) ? k + "(" : k;
};
document.getElementById("keys").appendChild(b);
}
</script>- Trigonometric functions use radians. The whitelist check stops arbitrary code from being run.
Topic 12
Even–odd, prime, table, factorial and Fibonacci
javascriptconst n = parseInt(prompt("Enter a number"), 10);
document.write(`${n} is ${n % 2 === 0 ? "even" : "odd"}<br>`);
let prime = n > 1;
for (let i = 2; i * i <= n; i++) if (n % i === 0) { prime = false; break; }
document.write(`${n} is ${prime ? "" : "not "}prime<br>`);
for (let i = 1; i <= 10; i++) document.write(`${n} × ${i} = ${n * i}<br>`);
let f = 1n; // BigInt for large factorials
for (let i = 2n; i <= BigInt(n); i++) f *= i;
document.write(`${n}! = ${f}<br>`);
let a = 0, b = 1, series = [];
for (let i = 0; i < n; i++) { series.push(a); [a, b] = [b, a + b]; }
document.write("Fibonacci: " + series.join(", "));Key terms
- Fragment link
- Link to an element id on the same page (#id)
- iframe
- Element embedding another page
- CSS animation
- Keyframe-based animation replacing marquee
- Form validation
- Checking input before submission
- BigInt
- JavaScript type for arbitrarily large integers
Quick revision
- Book index, tags, timetable with colspan and rowspan.
- Scrolling letterhead with CSS animation; in-page links.
- audio and video tags; flex or grid split layouts; iframes.
- Bio-data table; hospital page styled with CSS; college website.
- JavaScript login and registration validation; arithmetic, quadratic, greatest, grade, calculator, even–odd, prime, table, factorial, Fibonacci.
Important exam questions
Practice questions written to the PTU exam pattern for this unit's syllabus: short answers (Section A style) and long answers (Sections B and C style).
Short-answer questions
- Q1.Why is the marquee tag avoided today?
- Q2.How do you link to a section on the same page?
- Q3.Which tags embed audio and video?
- Q4.How do you read a number from a text box in JavaScript?
- Q5.How is a prime check made efficient?
- Q6.Why use BigInt for factorials?
Long-answer questions
- Q1.Design a college website with navigation and tutorial links.
- Q2.Design a registration form with JavaScript validation.
- Q3.Write a JavaScript program to solve a quadratic equation.
- Q4.Write a JavaScript scientific calculator.
Stuck on this unit?
Message SBS on WhatsApp for help with Web Technologies Laboratory, or to ask about studying M.Sc IT at Synetic.
