You are on page 1of 9

 Write a javascript program of event handling to show some message

after clicking on a button.

<!DOCTYPE html>

<html lang="en">

<head>

<script>

function click() {

document.write("Welcome");

</script>

<meta charset="UTF-8">

<meta http-equiv="X-UA-Compatible" content="IE=edge">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>nishan</title>

</head>

<body>

<script>

var button = document.createElement("button");

button.innerHTML = "click me";

var body = document.getElementsByTagName("body")[0];

body.appendChild(button);
button.addEventListener("click", function () {

alert("welcome to my website !");

});

</script>

</body>

</html>

 Write a javascript program for onmouse over & on mouse out events
with example.

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta http-equiv="X-UA-Compatible" content="IE=edge">

<meta name="viewport" content="width=, initial-scale=1.0">

<title>nishan</title>

</head>

<body>

<style>

img {
height: 200px;

width: 200px;

</style>

<img onmouseover="bigImg(this)"onmouseout="normalImg(this)"
border="0"

src="https://www.mindcontroversy.com/wp-
content/uploads/2014/03/Hanuman-.jpg">

<script>

function bigImg(x) {

x.style.height = "400px";

x.style.width = "400px";

function normalImg(x) {

x.style.height = "100px";

x.style.width = "100px";

</script>

</body>

</html>
 Make a html form having 3 fields of name, email and phone number
with submit button . write some validation code of form validation of
javascript which display error message when user try to submit
without filling this field.

<!DOCTYPE html>

<html lang="en">

<head>

<script>

function validateForm() {

let x = document.forms["myForm"]["fname"].value;

if (x == "") {

alert("Name must be filled out");

return false;

</script>

<link rel="stylesheet" href="index.css">

<title>nishan</title>

</head>

<body>

<section>

<div class="form-box">
<div class="form-value">

<form name="myForm" action="" onsubmit="return


validateForm()" method="post">

<h2>Registation form</h2>

<div class="inputbox">

<input type="text" required>

<label for="">enter your name</label>

</div>

<div class="inputbox">

<input type="email" required>

<label for="">enter your email</label>

</div>

<div class="inputbox">

<input type="number" required>

<label for="">enter your phone number</label>

</div>

<button>submit</button>

</div>

</form>

</div>

</div>
</section>

</body>

</html>

 Write a program in php which display sum ,subtract , multiplication,


divided of 30 & 50.

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta http-equiv="X-UA-Compatible" content="IE=edge">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>nishan</title>

</head>

<body>

<?php

$x = 30;

$y=50;

$sum = $x+$y;

$sub = $x-$y;

$mul = $x*$y;

$div = $x/$y;
echo $sum;

echo $sub;

echo $mul;

echo $div;

?>

</body>

</html>

 Write a php program to count 5 to 15 using php.

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta http-equiv="X-UA-Compatible" content="IE=edge">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>nishan</title>

</head>

<body>

<?php

for ($x = 5; $x <= 15; $x++) {

echo "The number is: $x <br>";


}

?>

</body>

</html>

 Create a database connectivity which connect to database with


message.

<?php

$servername = "localhost";

$username = "username";

$password = "password";

$conn = new mysqli($servername, $username, $password);

if ($conn->connect_error) {

die("Connection failed: " . $conn->connect_error);

echo "Connected successfully";

?>

 Create a table with following column roll no , name , class , subject , &
marks.

CREATE TABLE persons (

Rollno INT NOT NULL PRIMARY KEY AUTO_INCREMENT,

name VARCHAR(50) NOT NULL,


class INT NOT NULL UNIQUE

marks INT NOT NULL UNIQUE

);

-- Syntax for SQL Server Database

CREATE TABLE persons (

Rollno INT NOT NULL PRIMARY KEY IDENTITY(1,1),

name VARCHAR(50) NOT NULL,

class INT NOT NULL UNIQUE

subject VARCHAR(50) NOT NULL,

marks INT NOT NULL UNIQUE

);

You might also like