Friday, 15 November 2013

SQL:Working with Trigger and Transaction


  • Exercise 1

The management of AdventureWorks Incorporation has decided that no user should be able to change 
the prices of products. In addition, the management wants that all the attempts to change the price 
should be saved in a temporary table, Temp. John, the Database Developer, has been asked to make 
significant changes in the database to implement this policy. What should John do to achieve the same?

create Table Temp
(
ProductID int,
AttChangeCost money,
AttTime datetime
)


CREATE TRIGGER updTrigger ON
[Production].[ProductCostHistory] INSTEAD OF UPDATE
AS
BEGIN 
DECLARE @PID AS int
DECLARE @COST AS money
SELECT @PID=ProductID,
@cost=standardCost FROM Deleted
INSERT INTO Temp VALUES(@Pid,@cost,getdate())
select 'sorry you can not change the price of a product'
END


UPDATE [Production].[ProductCostHistory]
SET StandardCost=55
WHERE ProductID=707



  • Exercise 2

The management of AdventureWorks Incorporation wants that whenever the pay rate of an employee is modified, 
its effect on the monthly salary of that employee should be displayed. John, the Database Developer at 
AdventureWorks, has been asked to resolve this problem. Help John to find an appropriate solution.

CREATE TRIGGER updTrigger
ON HumanResources.EmployeePayHistory FOR UPDATE
AS 
BEGIN 
DECLARE @rate AS money
DECLARE @frq AS int
SELECT @rate = Rate,
@frq = PayFrequency FROM Inserted
SELECT @rate*@frq * 30 AS 'Monthly Salary'
END

UPDATE HumanResources.EmployeePayHistory
set Rate=Rate + 5

WHERE EmployeeID=160



  • Exercise 3

Create a trigger to ensure that the average of the values in the Rate column of the EmployeePayHistory table should not be more than 20 when the value of the rate is increased.

CREATE TRIGGER UpdatetriggerEPayHistory
ON HumanResources.EmployeePayHistory
FOR UPDATE
AS
IF UPDATE (rate)
BEGIN
DECLARE @AvgRate float
SELECT @avgRate= AVG(Rate)
FROM HumanResources.EmployeePayHistory
IF (@avgRate > 20)
BEGIN
PRINT 'The average value of rate cannot be more than  20'
ROLLBACK TRANSACTION
END

END



  • Exercise 4

Create a trigger on the Product table to ensure that if the value for the SafetyStockLevel column becomes less than or equal to the specified ReorderPoint column for a product because of an update operation, a message informing that the reorder level has been attained should be displayed.

create Trigger OrderStock
on Production.Product
for update
as
declare @PID varchar
select @PID=ProductID from inserted
if((select safetyStockLevel from INserted)<=
(select ReorderPoint from inserted))
Begin 
print'The stock of'+@PID+
'is under the reorder point'

end




  • Exercise 5

Create a trigger named Emp_Update on the EmployeeDetail table. This trigger should restrict a user from performing any kind of DML operation on the table before 9 A.M and after 5 P.M.

create trigger Emp_Update
on EmployeeDetail After insert, Update, delete
as
Begin
Declare @Time INT
set @Time=DateName (HH,GETDATE())
if @Time not Between 9 and 17
Begin
Rollback
print ('The operation cannot be performed before 9 am & after 5 pm')
end

end



  • Exercise 6

 The management of AdventureWorks wants that whenever the account number of a user is modified,  the old account number, as well as the new account number, should be instantaneously displayed to the user.  How can you accomplish the desired task?

 create trigger Vendoraccountnum
on Purchasing.Vendor
for Update as
Begin
Declare @oldvalue nvarchar(15)
Declare @newvalue nvarchar(15)
select @oldvalue=Accountnumber from deleted
select @Newvalue=Accountnumber from inserted
print 'The old account number is'+@oldvalue
Print 'The New account number is'+Newvalue

end



  • Exercise 7

Create a trigger named Emp_Delete_Trg on the EmployeeDetails table. This trigger should restrict the deletion of records from the table if the designation of an employee is Manager.

create trigger emp_Delete_Trg
on employeeDetails After Delete
as
Begin
Declare @job varchar(50)
select @job=Designation from deleted
if @job='Manager'
begin
Rollback
print ('Cannot Delete Manager from The Table')
end

end




  • Exercise 8

Create a trigger named Emp_Update_Trg that will restrict the updation of salary of an employee if the new salary is less than the previous salary in the EmployeeDetails table.

create trigger emp_Update_Trg
on EmployeeDetails After Update
as
Begin
Declare @oldSal money
Declare @NewSal money
select @oldSal=salary from deleted
select @NewSal=Salary from Inserted
if @OldSal>@NewSal
begin
Rollback
print ('New salary cannot be less than the old salary')
end

end



  • Exercise 9

 Create a trigger named Emp_Nested_Trg on the EmployeeDetails table for an insert operation. This trigger should ensure that a new record being inserted into the EmployeeDetails table has  a matching record in the DeptDetails table. Otherwise, the insert operation is rolled back.

create trigger Emp_Nestes_Trg
on EmployeeDetails After Insert
as
Begin
Declare @OptNo int
select @OptNo=OptNo from Inserted
If not Exists(select * from DeptDetails
Where DeptNo=@deptNo)
Print 'The specified DeptNo does not exist.'
Rollback

end



  • Exercise 10

Consider the following statement: 
CREATE VIEW Emp_Dept AS SELECT E.EmployeeID, E.EmpName, E.Designation, E.Salary, D.DeptNo, 
D.DeptName 
FROM EmployeeDetails E 
INNER JOIN DeptDetails D ON E.DeptNo=D.DeptNo 
A view named Emp_Dept has been created on the base tables, EmployeeDetails and DeptDetails, 
by using the preceding statement. John is the Database Developer with AdventureWorks Incorporation. 
He wants that the users should be able to insert data in the underlying base tables by using the 
view. He can implement the desired functionality if the insert operation affects a single table. 
However, the same cannot be done if multiple tables are involved. He wants to be able to insert 
data in both the tables with the help of a single insert statement. Help John in resolving the 
problem.

create trigger View_Insert_Trg
on Emp_Dept 
Instead of Insert
as
Begin
Insert into EmployeeDetails(EmployeeID,EMPName,
Designation, Salary,DeptNo)
select EmployeeID,EmpName,Designation,salary,DeptNo from Inserted
Insert into DeptDetails(DeptNo,DeptName)
select DeptNo,DeptName from Inserted

end



  • Exercise 11

John is a Database Developer. He is not able to delete the unwanted records from the base tables by using the view, Emp_Dept. Help John in resolving the problem.

create trigger view_delete_trg
on Emp_Dept 
Instead of delete
as
Begin
Declare @DeptNo int
declare @Count int
select @DeptNo=DeptNo from deleted
select @Count=Count(*) from EmployeeDetails
Where DeptNo=@DeptNo
delete from EmployeeDetails Where DeptNo=@DeptNo
if @Count=1
Delete from deptdetails where DeptNo=@deptNo

end

SQL-Implementing Stored Procedures and Functions


  • Exercise 1

Create a batch that finds the average pay rate of the employees and then list the details of the employees who have a pay rate less than the average pay rate.

declare @avg_rate int
select @avg_rate = AVG(rate)
from HumanResources.EmployeePayHistory
select * from HumanResources.EmployeePayHistory
where rate < @avg_rate


  • Exercise 2

Create a function that returns the shipment date of a particular order

create function Sales.CalShipDate(@SalesOrderID int)
returns Date
as
begin
declare @shipDate Datetime
select @shipDate=ShipDate
from Sales.SalesOrderHeader where SalesOrderID = 

@SalesOrderID
if (@shipDate IS NULL)
set @shipdate = 0
return @shipDate
end

select salesOrderID, Sales.CalShipDate(salesOrderID)
as ShippingDate
from Sales.SalesOrderHeader


  • Exercise 3

Create a function that returns the credit card number for a particular order.

create function Sales.DisplayCardNumber(@SalesOrderID int)
returns nvarchar(25)
as
begin
declare @ret nvarchar(25)
select @ret = CardNumber
from Sales.SalesOrderHeader s join sales.CreditCard c
on s.CreditCard = c.CreditCard
where salesOrderID = @SalesOrderID
if(@ret IS NULL)
set @ret =0
return @ret
end

select SalesOrderID, 'Credit Card Number' = Sales.DisplayCardNumber(SalesOrderID) from 
Sales.SalesOrderHeader


  • Exercise 4

Create a function that returns a table containing the ID and the name of the customers

create function sales.IndividualDetails (@format nvarchar(9))
returns @tbl_IndividualTable
(CustomerID int PrimaryKey, Name nvarchar(100))
as begin if(@format ='LONGNAME')
insert @tbl_IndividualTable
select Cu.CustomerID,FirstName+''+LastName
from PersonContact as C
join Sales.Individual as I
on C.ContactID=I.ContactID join Sales.Customer as Cu
on I.CustomerID = Cu.CustomerID
where Cu.CustomerType='I'
order by LastName,FirstName
else if(@format='SHORTNAME')
insert @tbl_Individual
select Cu.CustomerID,LastName from Person,Contact as C
join Sales.Individual as I on C.ContactID = I.ContactID
join sales.Customer as Cu on I.CustomerID = Cu.CustomerID where Cu.CustomerType = 'I'
order by LastName
return
end

select * from Sales.IndividualDetails('LONGNAME')
select * from Sales.IndividualDetails('SHORTNAME')


  • Exercise 5

Create a user-defined function that accept the account number of customer and returns...

create function fx_Disp_AccDet (@AccNum int)
returns table with schemabinding
as
return(
select Customer_name, Acc_num
from dbo.Depositor
where Acc_num = @AccNum
)

select * from fx_Disp_AccDet(101)



  • Exercise 6

Create a batch to check the availability of the product, Chaining Bolts, in the stock of the database

declare @MakeFlag bit
select @MakeFlag = MakeFlag from Production.Product
where Name = 'Chaining Bolts'
if @MakeFlag = 1
print 'The Stock is available'
else
print 'The Stock is not available'



  • Exercise 7

Create a stored procedure that accept the name of a product and display its ID, number and availability

create proc productList @name varchar(50)
as
begin
print 'Product Details'
select ProductID, ProductNumber, MakeFlag as Availability
from Production.Product
where Name = @name
end 

execute productList 'Keyed Washer'



  • Exercise 8

Create a stored procedure that returns the standard cost of a given product

create procedure prcGetCostDetails @ProductId int
@StandardCost money output
as
begin
if exists(select * from Production.ProductCostHistory
where ProductID = @productID)
begin
select @StandardCost = StandardCost
from Production.ProductionCostHistory
return 0
end
else
return 1
end



  • Exercise 9

Create a stored procedure that accepts two number, num1 and num2 and display the result after these 
numbers

create procedure vx_DIV @Num1 int,@Num2 int
as
begin
declare @Div int
if @Num1 < @Num2
raiserror('You have entered your number in the wrong  way',16,1)
else
set @Div=@Num1/@Num2
print @Div
end

SQL-Implementing index, views and full text


  • Exercise 2

The Store table is often queried. The queries are based in the CustomerID attribute and take along to execute

create unique nonclustered index Idx_CustomerID on Sales.Store(CustomerID)


  • Exercise 3

The SalesOrderDetail table is often queried

create nonclustered index Idx_SalesOrderId_SalesOrderDetailId on Sales.SalesOrderDetail(SalesOrderId, SalesOrderDetailId)



  • Exercise 4

A view has been defined as shown in the following statement
create view vxSalesOrderDetail 
as
select oh.SalesOrderID, TerritoryID, TotalDue, OrderQty, ProductID
from Sales.SalesOrderHeader oh join Sales.SalesOrderDetail od on oh.SalesOrderID=od.SalesOrderID
The following update statement gives an error when you update the OrderQty and TerritoryID attribute:
update vwSalesOrderDetail
set OrderQty=2, TerritoryID=4
from vwSalesOrderDetail
where SalesOrderID = 43659


Identify the problem and provide the solution
update vwSalesOrderDetail
set OrderQty=2
from vwSalesOrderDetail
where SalesOrderID = 43659

update vwSalesOrderDetail
set TerritoryID=4
from vwSalesOrderDetail
where SalesOrderID = 43659



  • Exercise 5

The Store table contains the details of all the stores.Write a query to retrieved the result set quickly

create fulltext catalog cat3 as default
create fulltext index on Sales.Store(Name)
key index PK_Store_CustomerID

select * from Sales.Store
where FreeText (name,'Bike')

select * from Sales.Store
where Contains (name,'"Bike Store"')



  • Exercise 6

Display the detail of all the credit crds are of type "SuperiorCard".Optimize the execution time.

create fulltext catalog cat4 as default

create fulltext index on Sales.CreditCard(CardType)
key index AK_CreditCard_CardNumber

select *from Sales.CreditCard
where Contains (CardType,'"SuperiorCard"')



  • Exercise 7

Display the details of all the currencies that contain the words 'New' and 'Dollar' in their name.Optimize the Result Set.

Create fulltext index on Sales.Currency(Name)
key index AK_Currency_Name

select *from Sales.Currency
where Contains (Name,'"New"') and (Name,'"Dollar"')



  • Exercise 8
The manager of the producion department wants to analyze the products that contain the exact word "road" in their description.Query to optimize the result set.

select * from Production.ProductDescription
where Contains (Description ,'road')


  • Exercise 9
The report of the all product that contain the exact word "top" near the word "line" in their description.Query to optimize the result set.

select Description, ProductDescriptionID from Production.ProductDescription
where Contains (Descripton,'"top" near "line"')


  • Exercise 10
Display the details of all the stores having the word 'bike' in their name.Also report contains the details of those stores that have the SalesPersonID as 277.Optimize the query

select * from  Sales.Store where
SalesPersonID =277 and Contains (Name,'Bike')


  • Exercise 11
The DepartmentHistory table of employee is often queried. The queries are based on the EmployeeID attribute and take a long time to execute.Optimize the execution

create nonclustered index Idx_EmployeeId
on HumanResousce.EmployeeDepartmentHistory(EmployeeID)


  • Exercise 12
The Store table is queried based on Demographical attribute and take a long time to execute.Optimize the execution

create xml index Sdx_Sales_Demographics_PATH 
on Sales.Store (Demographics)
using xml index PXML_Store_Demographics
FOR PATH


  • Exercise 13
Create a view to retrive the employeeIDs along with the corresponding Group Name.

create view Disp_Details 
as
select E.EmployeeId, D.GroupName 
from HumanResources.Department D
inner join
HumanResources.EmployeeDepartmentHistory E 
on D.DepartmentId = E.DepartmentId


  • Exercise 14
Create a view to retrive SalesOrderId and Price of the Product along with corresponding Product Name

create view vxSales
as
select P.Name, S.SalesOrderID, S.UnitPrice
from Production.Product P inner join
Sales.SalesOrderDetail S
on P.ProductID=S.ProductID


  • Exercise 15
Create a view to display salesOrderId, CustomerId, OrderQty, UnitPrice, SubTotal and TotalDue of the orders placed.

create view vxSale as
select H.CustomerID, H.SubTotal, H.TotalDue,
D.SalesOrderID, D.OrderQty, D.UnitPrice
from Sales.SalesOrderHeader as H 
join Sales.SalesOrderDetail as D 
on H.SalesOrderID = D.SalesOrderID

SQL-Manipulating Data in Table


  • Exercise2

Insert the data into the AdventureWorks database in demographical manner

Insert into Sales.Stores values(29484,'Car Store',283,
'<StoreSurvey xmlns="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/StoreSurvey">
<AnnualSales>350000</AnnualSales>
<AnnualRevenue>35000</AnnualRevenue>
<BankName>International Bank</BankName>
<BusinessType>BM</BusinessType>
<YearOpened>1980</YearOpened>
<Speciality>Road</Speciality>
<SquareFeet>7500</SquareFeet>
<Brands>AW</Brands>
<Internet>T1</Internet>
<NumberEmployees>7</NumberEmployees>
</StoreSurvey>',DEFAULT,DEFAULT)



  • Exercise 3

Update the VendorAddress in AdventureWorks database

Update Purchasing.VendorAddress
set AddressID=
(Select AddressID from Person.Address where AddressLine1 ='4151 Olivera'
AND City = 'Atlanta')
from Purchasing.VendorAddress va, Purchasing.Vendor v 
where va.VendorID = v.VendorID

AND v.Name = 'Comfort Road Bicycles'



  • Exercise 4

Delete all the records from the ProductBrand table in the NarrowFabrics database. Ensure that you do not delete the table.

truncate table ProductBrand



  • Exercise 6

Insert records in OfficeLocation in PictureLibrary database

USE PictureLibrary
GO
Insert into OfficeLocation(Office_ID,
Office_Manager, Office_Location)
values (1001,'Max',Geography::Parse('POINT(-83.0086 39.95954)'))



  • Exercise 7

Write a query to delete all the records whose designation is clerk

USE AdventureWorks
GO
delete EmployeeDetails Output
where Designation = 'Clerk'



  • Exercise 8

The users of AdventureWorks need to publish the details of all the customers and their address on the organization website

select c.CustomerID, TerritoryID,AccountNumber, CustomerType, AddressLine1, City, StateProvinceID, POstalCode
From Sales.Customer c JOIN Sales.CustomerAddress ca ON c.CustomerID = ca.CustomerID
JOIN Person.Address a
ON ca.AddressID = a.AddressID
FOR XML PATH ('Customer')



  • Exercise 9

The management of AdventureWorks require a list containing skills of all the candidates who have applied for a vaccany

select JobCandidateID,
Resume.value('declare namespace ns="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume";(/ns:Resume/ns:Name/ns:Name.First)[1]','nvarchar(20)') AS [First Name] ,
Resume.value('declare namespace ns="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume";(/ns:Resume/ns:Name/ns:Name.Last)[1]','nvarchar(20)') AS [Last Name] ,
Resume.value('declare namespace ns="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume";(/ns:Resume/ns:Name/ns:Name.Skills)[1]','nvarchar(max)') AS [Skills]
FROM HumanResources.JobCandidate



  • Exercise 10

The production of a bicycle at AdventureWorks involves a number of phases in xml format

WITH
XMLNAMESPACES ('http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ProductModelManuInstructions' AS pd)
select ProductModelID
from Production.ProductModel where
Instructions.exist('/pd:root/pd:Location[@LocationID=10]')=1



  • Exercise 11

There is a change in the production process of the bicycle with the product modelID 7

WITH
XMLNAMESPACES ('http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ProductModelManuInstructions' AS pd)
update Production.ProductModel 
set Instructions.modify('delete (/pd:root/pd:Location)[1]')
where ProductModelID = 7



  • Exercise 12

The details of the two employee designed as clerk have been removed from the EmployeeDetails table

merge EmployeeDetails_Backup as target
using EmployeeDetails as source
on (target.EmployeeID = source.EmployeeID)
when matched and
target.Designation <> source.Designation
then update set
target.Designation = source.Designation
when not matched then
insert values (source.EmployeeID, source.EmpName, source.Designation, source.Salary, source.DeptNo)
when not matched by source then
delete;



  • Exercise 14

Write a query to copy the records of sales with unit price greater than $2024.949 in a  new tables Sales_od

Select * into Sales_od from Sales.SalesOrderDetails where UnitPrice > 2024.949



  • Exercise 15

Insert Records with the following address in the Address table of the AdventureWorks database

insert Person.Address(AddressLine1,City,StateProvinceID,PostalCode) values ('2125 Yan Street','Bothell',79,'98011')

  • Exercise 16
You need to create a table named Student_Details to store the details of Student in the database...

create xml schema collection StudentInfo as '<schema xmlns="http://www.w3.org/2001/XMLSchema">
<element name="StudentName" type="string"/>
<element name="Address" type="string"/>
<element name="ContactNumber" type="int"/>
</schema>'

create table Student_details
(
StudentID int,
StudentInfo XML(StudentInfo)
)

Friday, 8 November 2013

JavaScript and Tables

As I have said I'll be back soon so this the codes of table and javascript

Program Code:(Main)
<html>
<head>
<title>Sample Programs</title>
<style type="text/css">
table{border:solid 1px green;background-color:aqua;}
th{background-color:gray;}
td{padding:10px;}
</style>
</head>
<body>
<h2>Introduction about Tables, JavaScript</h2>

<table><caption>Details of students</caption>
<th>Name</th>
<th>Branch</th>
<th>Marks</th>
<tr>
<td>John</td>
<td>CSE</td>
<td>87</td>
</tr>
<tr>
<td>David</td>
<td>Mechanical</td>
<td>89</td>
</tr>
<tr>
<td>Savita</td>
<td>Electronics</td>
<td>80</td>
</tr>
<tr>
<td>Surya</td>
<td>Electronics</td>
<td>50</td>
</tr>
<tr>
<td>Salman</td>
<td>Civil</td>
<td>83</td>
</tr>
</table>
<br/>
<iframe src="JavaS1.html" width="500" height="200" name="framedpage"></iframe>
<iframe src="JavaS2.html" width="500" height="200" name="framedpage"></iframe>
</body>
</html>


Save as JavaS1.html
<html>
<head>
</head>
<body>
<script type="text/javascript">
function changeThis(){
var formInput = document.getElementById('theInput').value;
document.getElementById('newText').innerHTML = formInput;
}
</script>
<p>You wrote: <span id='newText'></span> </p> 

<input type='text' id='theInput' placeholder="Write Here" size="40" /><br/>
<input type='button' onclick='changeThis()' value='See what you wrote'/>
</body>
</html>


Save as JavaS2.html
<html>
<head>
</head>
<body>
<script type="text/javascript">
var day="4";
switch(day)
{
case "1":
document.write("Monday");
break;
case "2":
document.write("Tuesday");
break;
case "3":
document.write("Wednesday");
break;
case "4":
document.write("Thrusday");
break;
case "5":
document.write("Friday");
break;
case "6":
document.write("Saturday");
break;
case "7":
document.write("Sunday");
break;
default:
document.write("Invalid Input");
break;
}

</script>


</body>
</html>

Transformations

Apply this codes to transform HTML elements
Note:- All the transformation examples are tested in Chrome

-webkit-    --> Used for safari and chrome browser
-o-            --> Used for Opera
-moz-        --> Used for Mozilla

Program code:
<!DOCTYPE html>
<html>
<head>
<title>Transformations
</title>
<style> 
div
{
width:100px;
height:100px;
background-color:blue;
border:1px solid black;
animation:myfirst 5s;
-webkit-animation:myfirst 5s; /* Safari and Chrome */
}
@keyframes myfirst /*IE9*/
{
0%   {background:red;}
25%  {background:yellow;}
50%  {background:blue;}
100% {background:green;}
}
@-webkit-keyframes myfirst /* Safari and Chrome */
{
0%   {background:red;}
25%  {background:yellow;}
50%  {background:blue;}
100% {background:green;}
}

div#divscale
{
margin:100px;
transform:scale(2,4);
-ms-transform:scale(2,4); /* IE 9 */
-webkit-transform:scale(2,4); /* Safari and Chrome */
transition:width 2s, height 2s, transform 2s;
-webkit-transition:width 2s, height 2s, -webkit-transform 2s; /* Safari */
}
div#divscale:hover
{
width:200px;
height:200px;
transform:rotate(180deg);
-webkit-transform:rotate(360deg); /* Safari */
}

#rota
{
width:200px;
height:100px;
position:absolute;
top:200px;
left:500px;
background-color:yellow;
/* Rotate div */
transform:rotate(30deg);
-ms-transform:rotate(30deg); /* IE 9 */
-webkit-transform:rotate(-30deg); /* Safari and Chrome */
}

#rota:hover
{
-webkit-transform:rotate(-40deg);
}

div#divskew
{
position:absolute;
top:200px;
left:900px;
background-color:green;
transform:skew(30deg,20deg);
-ms-transform:skew(30deg,20deg); /* IE 9 */
-webkit-transform:skew(30deg,20deg); /* Safari and Chrome */
}
div#divskew:hover{
transform:skew(30deg,20deg);
-ms-transform:skew(30deg,20deg); /* IE 9 */
-webkit-transform:skew(-30deg,-20deg); /* Safari and Chrome */
}
/*Text Effects*/
h1
{
color:blue;
text-shadow: 5px 5px 5px #ff0000;
}
</style>
</head>
<body>
<h1>Simple Transformation Examples</h1><hr/>
<div>Hello. This is an element.</div>
<div id="divskew">
This is skew text example.
</div>
<div id="divscale">Hello. This is a SCALE element.<br/>
HOVER ME!!
</div>
<div id="rota">
<h4>Hover Me</h4>
Hello!! Hover Me!!</div>
</body>
</html>

Soon Come with the tables in HTML 
Thanks!!

Thursday, 7 November 2013

HTML examples including CSS and Iframes

Copy Paste this code for simple HTML based webpage
1. Used Inline,Internal and External style sheets
2. Used iframe, video, details, summary and some basic tags
Note: you will need some images (html.png), video(1.webm) just save any pic n any video with the same name you will get the output 

Save this as .html extension
<!DOCTYPE html>
<html>
<head>
<title>Examples till CSS</title>
<link rel="stylesheet" type="text/css" href="style.css"/>
<style type="text/css">
nav a:hover{color:green;background-color:white;}
</style>
</head>
<body>
<div id="container">
<h1 style="color:brown;font-family:verdana;">All Examples covered in this Page of HTML</h1><hr/>
<nav>
<a href="uptoch4.html">Home Page</a> | <a href="aboutus.html">About Us</a> | <a href="contactus.html">Contact Us</a> | <a href="feedback.html">Feedback</a>
</nav><hr/>
<article>
<p>The website contains the elements like the <b>html tags</b> ,<i>Javascript</i>, <u>Cascading style sheets</u></p>
</article>
<aside>
Gives some information about the article contained in a webpage.
</aside>
<figure id="image1">
<figcaption>HTML5 Logo</figcaption>
<img src="images/html.png" width="200px" height="200px" alt="HTML5"/>

</figure>
<dl>
<dt>What is HTML</dt>
<dd>HTML is a markup language providing the elements attributes for the designing of the webpages</dd>
<dt>What is CSS</dt>
<dd>CSS is used for describing the look and feel of the webpages</dd>
<dt>What is JavaScript</dt>
<dd id="cleard">JavaScript is a scripting language used for validation checks and some function like date time mathematical operation. There are 2 types of JavaScript
<ol>
<li>Client Side Java Script</li>
<li>Server Side Java Script</li>
</ol></dd>
</dl>

<video id="video1" width="420px" height="320px" controls="controls" autoplay="autoplay" loop src="C:\Users\Aqib\Documents\HTML Excercise\Practice\videos\1.webm">
Your Browser doesn't support video
</video>
<iframe src="http://google.com" width="500" height="200" frameborder="0" name="framedpage"></iframe>
<p>To Open the page click on the link <a href="new.html" target="framedpage">Transition</a></p>
<details><summary>Page consist of </summary>
<p>It is the practise of HTML5 examples.</p>
<ul>
<li>CSS</li>
<li>JavaScript</li>
<li>JQuery</li>
</ul>
</details>
</div>
</body>
<footer>
Designed by: MD AQIB FERHAN
</footer>
</html>


Save this as style.css
<style>
h1{color:red;}
p{color:blue;font-family:cambria;font-size:15pt;}
details{color:maroon;font-family:calibri;}
body{background:aliceblue;}
#image1{position:absolute;top:150px;right:100px;}
#video1{position:absolute;top:390px;right:50px;}
ul{list-style-type:square;list-style-position:outside;}
dd #cleard{clear:both;}

</style>



Save this as new.html
<HTML> 
<HEAD> 
<STYLE> 
#listed 
{ 
width:px; 
height:20px; 
background:silver;
-webkit-transition:width 4s; 
/* Chrome */
-o-transition:width 4s; 
/* Opera */ 
} 
#listed:hover 
{ 
height:40px; 
} 
#list1{
visible:no;
}
</STYLE> 
</HEAD> 
<BODY> 
<DIV>
<ul id="listed">
<li>College Affiliation</li>
<ul>
<li id="list1">The college is affiliated to the NIIT Ltd.</li>
</ul>
</ul>
</DIV> 
</BODY> 

</HTML>

Save this image as html.png



I THINK I HAVE UPLOADED ALL THE RESOURCES. SOME MORE EXAMPLE WILL BE UPLOADED SHORTLY.