You are on page 1of 27

Client-Side Scripting

Introduction
Client-side scripting refers to the execution of scripts on
the client's web browser rather than on the web server. These scripts are
typically written in languages like JavaScript, which is the most common
client-side scripting language. The main purpose of client-side scripting is
to enhance the interactivity and responsiveness of web pages by allowing
the browser to execute code locally on the user's device.

JavaScript
JavaScript is a versatile and widely used programming language primarily
known for its role in web development. It is a client-side scripting
language that runs in web browsers, allowing developers to create
dynamic and interactive web pages.

Variable declaration
In JavaScript, variables are used to store and manage data, and operators
are used to perform operations on that data. Here are examples of
variable declaration and some common operators in JavaScript.

1. Let
Use “let” when you need to reassign the variable to a different value.

Code

Output

2. const
Use “const” when the variable should never be reassigned after its
initial assignment.

Code

Output

3. Var
In modern JavaScript, it is generally recommended to use “ let” and
“const” over “var” due to scoping differences.

Code

Output
Operators
JavaScript has a variety of operators that allow you to perform operations
on variables and values. Here's an overview of some of the main types of
operators in JavaScript.
Arithmetic Operators

Code Output

Comparison Operators

Code Output
Logical Operators

Code Output

loops:
In JavaScript, loops are used to repeatedly execute a block of
code as long as a certain condition is true. There are several types of
loops available in JavaScript, each with its own use cases. Here's an
overview of the main types of loops.

1. For Loop:
Code: Output:
2. while Loop:
Code: Output:

3. do-while Loop:
Code: Output:

Arrays And For-Each loop:


Arrays are a fundamental data structure
in JavaScript that allow you to store and manipulate collections of
elements. The” for-Each” loop is a convenient way to iterate over the
elements of an array. Let's explore how to work with arrays and use
the “for-Each” loop in JavaScript.

▪ Basic Array Operations:


Code: Output:


▪ Iterating Through Array with


Code: Output:

▪ Mapping Array Elements:


Code: Output:
Functions And Object:

Functions:
A function in JavaScript is a reusable block of code
that can be defined and executed. Functions can take parameters
(inputs), perform tasks, and return a value.

▪ Function Declaration:

Code: Output:

▪ Arrow Function:
Code: Output:
Objects:
Objects in JavaScript are used to store and organize data in
key-value pairs. Objects can have properties and methods.

▪ Object Constructor:

Code: Output:

▪ Object Methods:
Code: Output:

DOM (Document Object Model):


The DOM (Document Object
Model) is a programming interface for web documents. It represents
the structure of a document as a tree of objects, where each object
corresponds to a part of the document, such as elements, attributes,
and text.

Code: Output:
Event listeners:
In JavaScript, event listeners are used to handle and
respond to events triggered by user interactions or other actions. Event
listeners are attached to HTML elements, and they execute a function
(callback) when the specified event occurs.

Code: Output:

Stop-Watch:

HTML: CSS:
Output:
Server Side Scripting

Introduction:
Server-side scripting is a web server technology in
which a user's request is fulfilled by running a script directly on the web
server to generate dynamic web pages. This is in contrast to client-side
scripting, where scripts are executed by the user's browser. Server-side
scripting allows developers to create dynamic and interactive web
applications by processing data on the server before sending it to the
client's browser.

PHP:
PHP is a server-side scripting language
designed for web development. It can be embedded within HTML code
and is executed on the server. PHP is widely used for creating dynamic
web pages and interacting with databases.
Function:
Code: Output:

Forms Using GET-POST Method:


▪ GET Method:
Code:

Output:
▪ POST Method:

Code: Output:

Login form With Sanitize and Validation:


Code:
Output:
File Handling:
1. Opening File(Reading):
Code: Output:

2. Writing File(Creating):

Code: Output:
Error Handling:
Code: Output:

Cookies:
Code: Output:
Crude Operations:
CRUD stands for Create, Read, Update, and Delete,
which are the basic operations that can be performed on a database.
Here are examples of basic CRUD operations in PHP using MySQL:

1. Creating And Connecting DB:

Code:

Output:

2. Inserting Values in DB:


Code: Output:

3. Registration Form:
Code: Output:
4. Retrieving Data:
Code: Output:
Inheritance:

Code:

Output:
Table Of Content
❖ Client Side Scripting (Java Script):
▪ Variable Declaration
▪ let
▪ const
▪ Var

▪ Operators
▪ Arithmetic Operators
▪ Comparison Operators
▪ Logical Operators

▪ loops
▪ For Loop
▪ while Loop
▪ do-while Loop

▪ Arrays And For-Each loop:


▪ Basic Array Operations
▪ Iterating Through Array with for-Each
▪ Mapping Array Element

▪ Functions And Object:


▪ Function Declaration
▪ Arrow Function
▪ Object Constructor
▪ Object Methods

➢ DOM (Document Object Model)

➢ Event listeners
❖Server Side Scripting(PHP)
➢ Forms Using GET-POST Method:
▪ GET Method
▪ POST Method

➢ File Handling:
▪ Opening File(Reading)
▪ Writing File(Creating)

➢ Crude Operations:
▪ Creating And Connecting DB
▪ Inserting Values in DB
▪ Registration Form
▪ Retrieving Data

➢ Inheritance
➢ Function
➢ Login form With Sanitize and Validation
➢ Error Handling
➢ Cookie

You might also like