Web note
Web note
21.1
<html>
</html>
<title>NSBM</title>
<head>
<body>
09/11/2021lec2
<b>NSBM</b>
<br>
NSBM Green University<br>
<dl>
<dt>nsbm</dt>
<dd>nationl school of business
management</dd>
</dl>
16/11/2021lec3 <html>
<head>
Inserting a table <title>NSBM</title>
</head>
<body>
19. <table border> to draw the table border
<table border=1>
20. <tr height> height of the raw <tr height=200>
<td width=200>A</td>
21. <td width> table data width <td width=200 bgcolor="blue">B</td>
</tr>
22. <td><center></td> get to the center <tr height=200 bgcolor="pink">
<td><center>C</center></td>
<td>D</td>
23. <a href=….> </a> insert a link
</table>
24. <a herf= > <img src= > </a> insert a link with a picture
<a href="https://www.nsbm.ac.lk">NSBM</a>
<a href="https://www.nsbm.ac.lk">
<img src="nsbm.jpg" width="50">
</a>
25. <input type="submit" name="x" value="click">
</body>
</html>
23/11/2021lec4
All styles will “cascade” into a new virtual style sheet in the following rule order, where number
four has the highest priority:
1) Browser default
h1 <h1>nsbm</h1>
{
<p class="n">green university</p>
color:pink;
}
</body>
</html>
Q] Create a page with nsbm logo at the center but when the content is moving, logo should stay
at the same position.
<!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">
<link rel="stylesheet" href="style.css">
<title>Document</title>
<body>
<div class="text">
paragraph***
body
{
background-image: url("p1.png");
background-position: center;
background-size: 300px 100px;
background-repeat: no-repeat;
background-attachment: fixed;
}
h1
{
color:rgb(224, 121, 169);
}
.text{
text-align: center;
font-size: 2rem;
position: absolute;
}
30/11/2021lec5
<html>
<head>
<title>NSBM</title>
<style>
h1.rdu
color:red;
text-decoration:underline;
</style>
</head>
<body>
<h1 class="rdu">nsbm</h1>
<h1 id="g">nsbm</h1>
<h1>nsbm</h1>
<h1>nsbm</h1>
<h1 class="rdu">nsbm</h1>
<h1>nsbm</h1>
<h1>nsbm</h1>
<h1>nsbm</h1>
<h1 class="rdu">nsbm</h1>
</body>
</html>
07/12/2021lec6
JAVASCRIPT
T
DHTML
Web Scripting
Advantages of JavaScript
Comments
<html>
<title>nsbm</title>
<body>
<script language="javascript" type="text/javascript">
document.write("hello World")
</script>
</body>
</html>
Q] Create a program to get two integer inputs from the user and display the answers for four
basic arithmetic operations.
test4 = test1-test2;
document.write("subtraction is " +test4, "<br>");
test5 = test1*test2;
document.write("multiplication is " +test5, "<br>");
test6 = test1/test2;
document.write("division is " +test6, "<br>");
</script>
JavaScript Popup Boxes
❖ An alert box
❖ Prompt box
JavaScript functions
<html>
<head>
<script language="javascript" type="text/javascript">
function x(s)
{
document.write("welcome "+s);
}
</script>
</head>
<body>
<script language="javascript" type="text/javascript">
s=prompt("enter name","");
x(s);
</script>
</body>
</html>
<html>
<head>
<script language="javascript" type="text/javascript">
function x()
{
alert("welcome" );
}
</script>
</head>
<body>
<input type="button" value="click" onClick="x()">
</body>
</html>
13/12/2021lec7
JavaScript functions
JavaScript events
Event handler
Mouse events
OnClick - user clicks the element with the left mouse button
Ondbclick - user double clicks the element with the left mouse button
Onmousedown – user presses either mouse button while the mouse pointer is
over the element.
Onmouseup - user releases either mouse button while the mouse pointer is
over the element.
Onmouseover – user moves the mouse pointer into boundaries of the element.
Onmousemove – user moves the moves pointer while the pointer is over the
element
Onmouseout – user moves the mouse pointer out of the boundaries of the
element.
<script language="JavaScript" type="text/javascript">
function x()
{
document.body.style.backgroundColor="pink"
}
function y()
{
document.body.style.backgroundColor="blue"
}
</script>
</head>
<body>
<a href="www.nsbm.ac.lk" onmouseover="x()"
onmouseout="y()">NSBM WEB</a>
</body>
<script type="text/javascript">
function displaymessage()
{
alert("hello world");
}
</script>
</head>
<body>
<form>
<input type="button" value= "Click me!" onclick = "displaymessage()">
</form>
</body>
Eg: form object is a property of the document eg: data object supplies the method getDay()
object , geHours(), getMinutes() that you an use to
extract information from the objects
Object.property object.method(p1,p2,………,pn)
Document.write()
The write () method of the document object
window object has dozens of objects and methods associated with it.
→ window.alert( )
→ window.prompt( )
→ window.confirm( )
→ windw.open( )
→ window.close( )
→ window.resizeTo(x,y)
form validation
the real benefit of using JavaScript with your forms is to perform validation of user input.
Validation allows you to ensure that the user has filled in all required fields and that valid fata
has been entered in those fields.
Document object
form validation
the real benefit of using JavaScript with your forms is to perform validation of user
input. Validation allows you to ensure that the user has filled in all required fields and
that has been entered in those fields.
Q] username should not be empty and password should contain 6 characters.
<html>
<head>
<title>Name</title>
<script language= "JavaScript" type="text/javascript">
function Validatetext()
{
if((document.f1.un.value.length <
1)&&(document.f1.pass.value.length<1))
{
window.alert("missing content!! please correct");
return;
}
if(document.f1.pass.value.length < 6)
{
window.alert("password should be 6 characters");
return;
}
}
</script>
</head>
<body>
<form method=post name="f1">
<b> Username: </b>
<input name="un" type="text" size="15" maxlength="20" value=""><br>
<b> Password: </b>
<input name="pass" type="text" size="15" maxlength="20" value=""><br>
<input type="button" value="Validate" onclick="Validatetext()">
</body>
</form>
</html>
04/01/2022lec8
PHP
Php is a saver-side scripting language for creating dynamic and interactive web pages.
Ie. Code is executed on the saver.
A PHP [age will generally contain PHP elements with HTML tags and other textual
content.
PHP is case sensitive.
<html>
<body>
server <?php PHP
………………. Parser
<html>
<body>
client <?php Database
Content……
All PHP code must be included inside one of the following markup tags.
<html>
<body>
<h1>MY first PHP Page</h1>
<?php
echo "<h2>Hello World</h2>";
?>
</body>
</html>
11/01/2022lec9
<html>
<body>
<?php
echo"<b><u><font color=red>NSBM</font></u></b>";
?>
</body>
<html>
Variables
All variables must begin with a dollar ($) sign followed by a meaningful name.
The name can contain any letter, number or the underscore, but the name cannot begin with a
number.
Eg: $abc
$my_abc
$var123
Arrays
<html>
<body>
<h1> PHP with array1</h1>
<?
$colors =array("Fire"=> "Red", "Sea"=> "Blue");
$col = $colors["Sea"];
echo "<h2>The Sky is $col<h2>";
?>
</body>
</html>
Q] create a form to enter your name and display welcome + your name, using PHP.
<html>
<head>
<title>NSBM</title>
<body>
</body>
</head>
</html>
<?php
$abc=$_REQUEST["C"];
echo "welcome $abc";
?>
18/01/2022lec10
<html>
<head>
<title>nsbm</title>
<body>
<form name="g"method="post" action="form.php">
Gender:
<input type="radio" name="g" value="female">Female
<input type="radio" name="g" value="male">Male<br><br>
Qualification
<input type="checkbox" name="a" value="ol">O/L
<input type="checkbox" name="b" value="al">A/L
<br><br>
country:
<select name="r">
<option value="1">srilanka</option>
<option value="1">india</option>
<option value="1">china</option><br>
</select><br><br>
Database connectivity
<?php
$server="localhost";
$user = "root";
$pw = "";
$db = "web1";
if($sconn->connect_error)
{
die("Connection failed:".$conn->connect_error);
}
else
{
echo "success";
}
?>
01/02/2022lec11
Q] create a PHP program to receive the name from a text box and to insert the name and the
system time to the database.
Q] create a PHP program to edit the name which was entered earlier? (get the old name & new
name from the user)
Q] create a PHP program to delete the specific record from the database.
08/02/2022lec12
15/02/2022lec13
<?php
$fname=$_FILES["photo"]["name"];
$ftemp=$_FILES["photo"]["tmp_name"];
echo $fname;
echo "<br>";
echo $ftemp;
// $flag=move_uploaded_file($ftemp,"D:/$fname");
// if($flag)
// {echo "File moved successfully";}
// else
// {echo " Sorry couldn't move";}
?>