Lesson 6.9 β Mini Project: Interactive Web Page
π Building a Complete Interactive Website Using HTML, CSS & JavaScript
π― Learning Objectives
After completing this lesson, students will be able to:
β Combine HTML, CSS, and JavaScript
β Use Variables
β Use Functions
β Use Events
β Use DOM Manipulation
β Create Interactive User Interfaces
β Build Real-World JavaScript Projects
π Introduction
Congratulations! π
You have learned:
β Introduction to JavaScript
β Variables & Data Types
β Operators
β Conditional Statements
β Loops
β Functions
β Events
β DOM Manipulation
Now it’s time to combine everything into a complete:
π Interactive Web Page Project
π Project Overview
We will create:
Student Information Portal
Features:
β Enter Student Name
β Display Welcome Message
β Change Background Color
β Show Student Details
β Interactive Buttons
β DOM Manipulation
π― Project Layout
----------------------------------
Student Information Portal
----------------------------------
Enter Name
[____________]
[ Show Welcome ]
[ Change Color ]
[ Show Details ]
----------------------------------
Output Area
----------------------------------
ποΈ Project Files
Create:
index.html
style.css
script.js
π― Step 1 β Create HTML Structure
index.html
<!DOCTYPE html>
<html>
<head>
<title>Interactive Web Page</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>
Student Information Portal
</h1>
<input type="text"
id="studentName"
placeholder="Enter Your Name">
<br><br>
<button onclick="showWelcome()">
Show Welcome
</button>
<button onclick="changeColor()">
Change Color
</button>
<button onclick="showDetails()">
Show Details
</button>
<div id="output">
Result Appears Here
</div>
<script src="script.js"></script>
</body>
</html>
π― Step 2 β Create CSS Design
style.css
body{
font-family:Arial;
text-align:center;
padding:50px;
background:#f5f5f5;
}
h1{
color:#0d6efd;
}
input{
padding:10px;
width:250px;
font-size:16px;
}
button{
padding:10px 20px;
margin:5px;
background:#0d6efd;
color:white;
border:none;
cursor:pointer;
border-radius:5px;
}
button:hover{
background:#084298;
}
#output{
margin-top:30px;
padding:20px;
background:white;
border-radius:10px;
box-shadow:0 0 10px lightgray;
font-size:20px;
}
π― Step 3 β Create JavaScript Functions
script.js
function showWelcome()
{
let name =
document.getElementById("studentName").value;
document.getElementById("output").innerHTML =
"Welcome " + name;
}
π Understanding the Code
Get user input:
document.getElementById("studentName").value
Display message:
document.getElementById("output").innerHTML
π― Step 4 β Change Background Color
Add to:
script.js
function changeColor()
{
document.body.style.backgroundColor =
"lightblue";
}
Output
Click:
Change Color
Background becomes:
Light Blue
π― Step 5 β Show Student Details
Add:
function showDetails()
{
let name =
document.getElementById("studentName").value;
document.getElementById("output").innerHTML =
"Student Name: " + name +
"<br>Branch: Computer Science" +
"<br>College: Government Polytechnic";
}
Output Example
If user enters:
Rahul
Display:
Student Name: Rahul
Branch: Computer Science
College: Government Polytechnic
π Complete JavaScript Code
script.js
function showWelcome()
{
let name =
document.getElementById("studentName").value;
document.getElementById("output").innerHTML =
"Welcome " + name;
}
function changeColor()
{
document.body.style.backgroundColor =
"lightblue";
}
function showDetails()
{
let name =
document.getElementById("studentName").value;
document.getElementById("output").innerHTML =
"Student Name: " + name +
"<br>Branch: Computer Science" +
"<br>College: Government Polytechnic";
}
π― Project Features Used
| Concept | Used |
|---|---|
| Variables | β |
| Functions | β |
| Events | β |
| DOM Manipulation | β |
| Input Fields | β |
| Buttons | β |
π Adding Conditional Statement
Improve Welcome Button:
function showWelcome()
{
let name =
document.getElementById("studentName").value;
if(name == "")
{
document.getElementById("output").innerHTML =
"Please Enter Your Name";
}
else
{
document.getElementById("output").innerHTML =
"Welcome " + name;
}
}
Output
If input is empty:
Please Enter Your Name
Otherwise:
Welcome Rahul
π― Adding Counter Using Variables
HTML
<button onclick="countClick()">
Count Click
</button>
JavaScript
let count = 0;
function countClick()
{
count++;
document.getElementById("output").innerHTML =
"Button Clicked " + count + " Times";
}
Output
First Click:
Button Clicked 1 Times
Second Click:
Button Clicked 2 Times
π Complete Professional Version
Features:
β Welcome Message
β Student Details
β Input Validation
β Background Color Change
β Click Counter
β Dynamic Output Area
π» Final Complete Project
index.html
<!DOCTYPE html>
<html>
<head>
<title>Interactive Web Page</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>
Student Information Portal
</h1>
<input type="text"
id="studentName"
placeholder="Enter Your Name">
<br><br>
<button onclick="showWelcome()">
Show Welcome
</button>
<button onclick="changeColor()">
Change Color
</button>
<button onclick="showDetails()">
Show Details
</button>
<button onclick="countClick()">
Count Click
</button>
<div id="output">
Result Appears Here
</div>
<script src="script.js"></script>
</body>
</html>
script.js
let count = 0;
function showWelcome()
{
let name =
document.getElementById("studentName").value;
if(name == "")
{
document.getElementById("output").innerHTML =
"Please Enter Your Name";
}
else
{
document.getElementById("output").innerHTML =
"Welcome " + name;
}
}
function changeColor()
{
document.body.style.backgroundColor =
"lightgreen";
}
function showDetails()
{
let name =
document.getElementById("studentName").value;
document.getElementById("output").innerHTML =
"Student Name: " + name +
"<br>Branch: Computer Science" +
"<br>College: Government Polytechnic";
}
function countClick()
{
count++;
document.getElementById("output").innerHTML =
"Button Clicked " + count + " Times";
}
π― Expected Output
User enters:
Rahul
Button Click:
Show Welcome
Output:
Welcome Rahul
Button Click:
Show Details
Output:
Student Name: Rahul
Branch: Computer Science
College: Government Polytechnic
π« Real World Applications
This project demonstrates concepts used in:
β Student Management Systems
β Online Registration Forms
β LMS Platforms
β Attendance Systems
β College Portals
β Dashboard Applications
β οΈ Common Beginner Mistakes
Mistake 1
Wrong ID Name
document.getElementById("name")
HTML:
id="studentName"
IDs must match.
Mistake 2
Missing Function Parentheses
Wrong:
onclick="showWelcome"
Correct:
onclick="showWelcome()"
Mistake 3
Forgetting Script File Link
<script src="script.js"></script>
Must be added.
π Best Practices
β Use meaningful function names.
β Validate user input.
β Keep code organized.
β Separate HTML, CSS, and JavaScript files.
β Test every feature.
π Module 6 Final Project Challenge
Create your own:
Polytechnic Student Portal
Include:
β Student Name
β Roll Number
β Branch
β Semester
β Welcome Message
β Color Changer
β Student Details Viewer
π Practical Activity
Create:
College Admission Portal
Features:
- Name Input
- Email Input
- Course Selection
- Submit Button
- Success Message
Using JavaScript and DOM Manipulation.
π Assignment
Assignment 6.9
- Which concepts are used in this project?
- Why is DOM Manipulation important?
- How are Events used?
- Why are Functions useful?
- Add a Reset Button to the project.
- Add another button to change text color.
- Modify the project for a College Admission Form.
π§ Quiz
Q1. Which JavaScript feature changes webpage content?
A. Loop
B. DOM Manipulation
C. Variable
D. Operator
β Answer: B
Q2. Which event is used for button clicks?
A. onload
B. onsubmit
C. onclick
D. onkeyup
β Answer: C
Q3. Which property gets text box data?
A. innerHTML
B. style
C. value
D. src
β Answer: C
Q4. Which keyword creates a function?
A. create
B. define
C. function
D. method
β Answer: C
Q5. This project combines?
A. Events
B. Functions
C. DOM Manipulation
D. All of These
β Answer: D
π Module 6 Summary
You have successfully learned:
β Lesson 6.1 β Introduction to JavaScript
β Lesson 6.2 β Variables & Data Types
β Lesson 6.3 β Operators
β Lesson 6.4 β Conditional Statements
β Lesson 6.5 β Loops
β Lesson 6.6 β Functions
β Lesson 6.7 β Events
β Lesson 6.8 β DOM Manipulation
β Lesson 6.9 β Mini Project: Interactive Web Page