WT Writing[1]
WT Writing[1]
Output:-
ATTRIBUTE DESCRIPTION
Text Field: <input type=”text”> Displays a single-line text input field.
Radio Button: <input type=”radio”> Displays a radio button for selecting one of many
choices.
Checkbox: <input type=”checkbox”> Displays a checkbox for selecting zero or more of
many choices.
Submit Button: <input type=”submit”> Displays a submit button for submitting the form.
Button: <input type=”button”> Displays a clickable button.
Output:-
Output:-
Output:-
2.(b) Aim: Develop a student registration form with validation support using javascript.
Theory: The JavaScript client-side mechanism provides many advantages over traditional CGI server-
side scripts. JavaScript can be used to trap user-initiated events such as button clicks, link
navigation, and otheractions that the user initiates explicitly or implicitly. The JavaScript code is
executed when the user submits the form, and only if all the entries are valid, they would be submitted
to the Web Server.
Output:-
2.(c) Aim: Develop a Dynamic website using Event Handling.
Theory: JavaScript Events are actions or occurrences that happen in the browser. They can be
triggered by various user interactions or by the browser itself. Common events include mouse clicks,
keyboard presses, page loads, and form submissions. Event handlers are JavaScript functions that
respond to these events, allowing developers to create interactive web applications.
EVENT DESCRIPTION
<HTML element event-type=”onclick”> Triggered when an element is clicked.
<HTML element event-type=”onmouseover”> Fired when the mouse pointer moves over an
element.
<HTML element event-type=”onmouseout”> Occurs when the mouse pointer leaves an element.
<HTML element event-type=”onkeydown”> Fired when a key is pressed down.
<HTML element event-type=”onkeyup”> Fired when a key is released.
<HTML element event-type=”onchange”> Triggered when the value of an input element
changes.
<HTML element event-type=”onload”> Occurs when a page has finished loading.
<HTML element event-type=”onsubmit”> Fired when a form is submitted.
<HTML element event-type=”onfocus”> Occurs when an element gets focus.
<HTML element event-type=”onblur”> Fired when an element loses focus.
Output:-
Event Date:-
Event OnKeyUp:-
Event Click:-
2.(d) Aim: Develop DOM manipulation using Javascript.
Theory: HTML DOM is a standard object model and programming interface for HTML documents.
With HTML DOM, we can easily access and manipulate tags, IDs, classes, attributes, or elements of
HTML using commands or methods provided by the document object. Using DOM JavaScript we get
access to HTML as well as CSS of the web page and can also modify the behavior of the HTML
elements.
Output:-
PROGRAM-3: Server side programming using node.js
Output:-
1.
2.
3.
4.
5.
6.
Output:-
Output:-
Output:-
Output:-
Rendering HTML:-
Rendering JSX:-
4.(b) Aim: Execute React props, events, lists, forms and router.
Theory: React props are read-only attributes passed from parent to child components in React to
customize rendering. React uses synthetic events to handle user actions (like clicks) in a way that’s
consistent across all browsers. Arrays can be rendered as lists using the map() function, with each item
requiring a unique key prop. Forms allow react to track user input and handle form submission. React
router facilitates navigation within a single-page application, handling different URLs and rendering
appropriate components.
EVENT DESCRIPTION
onInput This event fires when the value of input field gets
changed.
onSubmit This event is triggered when the user submits a
form using the submit button.
onFocus This event fires when the user clicks on any input
tag and that tag activates to receive data.
onBlur This event occurs when the element is no longer
active.
Output:-
React Event:-
React Form:-
React List:-
4.(c) Aim: Implement a REST service from Node.js and display SPA.
Theory: REST service uses HTTP methods (GET, POST, etc.) to interact with resources in a stateless
manner. An SPA (Single Page Application) is a web application that loads a single HTML page and
dynamically updates content as the user interacts with the app.
Output:-
5.(b) Aim: Creating collections, retrieving data, inserting, updating, and querying the databases
Theory: In MongoDB, collections can be created manually or automatically when a document is
inserted. Data is added to a collection using the insertOne method for single documents or insertMany
for multiple documents. The find method is used to query documents in a collection based on given
criteria. Methods like updateOne and updateMany are used to modify existing documents based on a
specified query. MongoDB provides various operators like $eq, $gt, and $in to construct flexible and
powerful queries.
Program:-
use College
db
show dbs
db.Students.insertOne({ID:1, Name:'Alekhya', Age:20, Dept:'CSE'});
show dbs
db.Students.insertMany([{ID:2, Name:'Balu', Age:19, Dept:'ECE'}, {ID:3, Name:'Chanti', Age:21,
Dept:'EEE'} ]);
db.Courses.insertMany([{CourseID:101, CourseName:'Data Structures', Credits:4}, {CourseID:201,
CourseName:'Basic Electronics', Credits:3}, {CourseID:304, CourseName:'BEE', Credits:4}]);
db.Departments.insertMany([{Name:'CSE', FacultyCount:25}, {Name:'ECE', FacultyCount:32},
{Name:'EEE', FacultyCount:21}]);
db.Students.find()
db.Students.find({Dept:'CSE'});
db.Courses.find({CourseID:201});
db.Students.updateOne({ID:3}, {$set: {Name:'Sameera'}});
db.Students.find()
db.Departments.updateMany(
{ FacultyCount: 25 },
{ $set: { FacultyCount: 19, Name:'Civil'} }
);
db.Departments.find();
db.Courses.deleteOne({ CourseName: 'Data Structures' });
db.Courses.find();
show collections
db.Courses.drop();
show collections
Output:-
Create Database, Current Database & View Databases:-
Drop Collection:-
5.(c) Aim: Connection with Node.js
Steps to Connect Node to a MongoDB Database:-
Step-1: Install mongoose in your system using the below command.
To connect a Node.js application to MongoDB, we have to use a library called Mongoose.
Then we have to define a schema. A schema is a structure, that gives information about how the data is
being stored in a collection.
Step-4: Define the Schema.
Example: Suppose we want to store information from a contact form of a website.
const contactSchema = {
email: String,
query: String,
};
Then we have to create a model using that schema which is then used to store data in a document as
objects.
Step-5: Create a Model with the defined schema.
const Contact = mongoose.model("Contact", contactSchema);