Hands-on laboratory exercises in JavaScript, jQuery, and PHP/MySQL
Grade XII • Computer Science Lab • Capstone ⏱️ ~45-50 minBrief Intro — Web Tech II Lab
This is your workshop: do the exercises, break things, fix them, and ship your own build at the end. You'll work through 32 lab exercises covering JavaScript fundamentals, DOM manipulation, events, loops, objects, validation, jQuery, and PHP/MySQL database connectivity.
The Mini Browser simulator below lets you type and run JavaScript code in real-time. Use it to test the lab exercises and experiment with different approaches.
Type JavaScript code below and click Run to see it execute in the sandbox.
Basic JavaScript exercises: alerts, DOM manipulation, and output methods.
Task 1: First JavaScript & DOM Manipulation (Labs 1-4)
Create a page that alerts "Hello JavaScript" on load, change element content with getElementById, change image src, and set fontSize.
Answer: Use alert() for popups. Use getElementById() to select elements. innerHTML changes content. src changes image source. style.fontSize changes text size.
Task 2: Show/Hide & Output Methods (Labs 5-10)
Show/hide elements, display (5 + 6) using innerHTML, alert, document.write, console.log, and window.print().
Answer: innerHTML displays in element. alert() shows popup. document.write() writes to page. console.log() logs to console. window.print() prints page. display property controls visibility.
Task 3: Functions (Labs 11-12)
Write functions for multiplication and Fahrenheit to Celsius conversion.
Answer: Define functions with parameters. Use return to send values back. Call functions with arguments. Display results in page elements.
Interactive elements, event handlers, and control structures.
Task 4: Events & Toggle (Labs 13-14)
Toggle light on/off with onclick, add onclick to change element content.
Answer: Use onclick event attribute or addEventListener(). Toggle changes between two states. onclick handlers trigger functions that modify page content.
Task 5: Events & Time Greetings (Labs 15-18)
Illustrate events (onload, onchange, onmouseover) and time-based greetings with if/else and switch.
Answer: Events trigger code on user actions. if/else handles two conditions. if-else if-else handles multiple conditions. switch handles multiple cases with single expression.
Task 6: Loops (Labs 19-22)
Use for, for-in, forEach(), and for-of loops to iterate.
Answer: for loop iterates with counter. for-in iterates object properties. forEach() iterates array values. for-of iterates iterable values like strings/arrays.
JavaScript objects and form validation techniques.
Task 7: Person Object (Lab 23)
Create a person object with properties and a fullName method.
Answer: Objects hold properties and methods. Use this keyword to reference object properties. Methods are functions that operate on object data.
Task 8: Form Validation (Labs 24-25)
Validate numeric input > 1 and < 10, and check if form field is empty.
Answer: Validate input conditions with if statements. Display alert messages on failure. Return false in onsubmit to prevent form submission when validation fails.
jQuery library for simplified DOM manipulation and events.
Task 9: jQuery Selectors & Events (Labs 26-28)
Hide elements with jQuery selectors and illustrate jQuery events.
Answer: jQuery uses $() with CSS-style selectors. $("p") selects paragraphs. $("#demo") selects by id. jQuery provides event methods like click(), hover(), focus().
Server-side scripting with PHP and database connectivity.
Task 10: PHP Fundamentals & Classes (Labs 29-30)
PHP text/number manipulation and object class with constructor.
Answer: PHP uses <?php ?> tags. Variables start with $. echo displays content. Classes have __construct() for initialization. this keyword references object properties.
Task 11: MySQL Connection & Operations (Labs 31-32)
Connect to MySQL, create database/table, insert and display records.
Answer: Use new mysqli() to connect. Check connect_error for failures. Use SQL CREATE DATABASE/TABLE to structure data. INSERT adds records. SELECT retrieves data. Close connection when done.
Your final project: build a working web feature from scratch.
Task 12: Capstone Project
Choose ONE concept and build your own interactive web page.
Verification: Does your page work in browser? Are all interactive elements functional? Is validation working? Is the design clean and usable? Can you demonstrate it to your teacher?
Ready to test your knowledge?
Take the Assessment →