Thursday, 30 March 2017

Javascript and MS-Access data connectivity(insert and display records)

Create an employee database in ms-access as follows
Write javascript code as follows
------------------------------------------

1) Add_form.html
 ----------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

    <title></title>

    <script type="text/javascript" >

        function InsertRecord()

        {

            var txtid = document.getElementById('txtid').value;

            var txtname = document.getElementById('txtname').value;

            var txtsalary = document.getElementById('txtsalary').value;

            var txtcity = document.getElementById('txtcity').value;

            if (txtid.length != 0 || txtname.length !=0 || txtsalary.length !=0|| txtcity.length !=0)

            {

                var connection = new ActiveXObject("ADODB.Connection");

var connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source =D:/JAVASCRIPTDB/EmpDetail.mdb;Persist Security Info=False";

                connection.Open(connectionstring);

                var rs = new ActiveXObject("ADODB.Recordset");

 rs.Open("insert into Emp_Info values('" + txtid + "','" + txtname + "','" + txtsalary + "','" + txtcity + "')", connection);

                alert("Insert Record Successfuly");

                txtid.value = " ";

                connection.close();

            }

            else

            {           

                alert("Please Enter Employee \n Id \n Name \n Salary \n City ");

            }

        }

       

    </script>

    <style type="text/css">

        #main

        {

            height: 264px;

        }

        #ShowRecord

        {

            width: 67px;

            z-index: 1;

            left: 20px;

            top: 257px;

            position: absolute;

        }

        #showall

        {

            z-index: 1;

            left: 114px;

            top: 257px;

            position: absolute;

        }

    </style>

</head>

<body style="height: 431px">

    <div id="show"

        style="font-size: x-large; font-weight: bold; height: 298px; color: #009999;">

       Insert Employee Record<p style="font-size: medium; color: #000000;">

     Employee Id&nbsp;&nbsp;

    <input id="txtid" type="text" /></p>

        <p style="font-size: medium; color: #000000;">

            Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

            <input id="txtname" type="text" /></p>

        <p style="font-size: medium; color: #000000;">

            Salary&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

            <input id="txtsalary" type="text" /></p>

        <p style="font-size: medium; color: #000000;">

            City&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

            <input id="txtcity" type="text" /></p>

    <input id="ShowRecord" type="button" value="Insert" onclick="InsertRecord()" />&nbsp;


    </body>

</html>

----------------------------------------------------------------------------------------
2.show_detals_form.html
----------------------------------------------------------------------------------------
<html>
<center>
<h2 style="font-family:algerian; color:#A06D3F">Want to See the daetails!! </h2>
<head>
<title>Entitled Document</title>

<script language="JavaScript">
function getdetails()
{
i=1;
var cn = new ActiveXObject("ADODB.Connection");
    var strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = D:/JAVASCRIPTDB/EmpDetail.mdb;Persist Security Info=False";
    cn.Open(strConn);
    var rs = new ActiveXObject("ADODB.Recordset");
    var SQL = "select * from Emp_Info";
  rs.Open(SQL, cn);
rs.MoveFirst
while(!rs.eof)
{
document.write( "<h5>&nbsp;&nbsp;&nbsp;"+i,rs('txtid')+"&nbsp;&nbsp;&nbsp;",rs('txtname')+"&nbsp;&nbsp;&nbsp;",rs('txtsalary')+"&nbsp;&nbsp;&nbsp;",rs('txtcity')+"</h5>");
rs.movenext;
i=i+1;
}
rs.Close();
cn.Close();


}

</script>
</head>
<body bgcolor="#FFFFFF">
<input type="button" value="Click here" onclick="getdetails()">
</body>
</html>
---------------------------------------------------------------------------
3. display_record.html
---------------------------------------------------------------------------
    <html>
    <head>
    <title>Entitled Document</title>
    <script language="JavaScript">
    function getSubmit()
    {
i=1;
       var cn = new ActiveXObject("ADODB.Connection");
    var strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = D:/JAVASCRIPTDB/EmpDetail.mdb;Persist Security Info=False";
    cn.Open(strConn);
    var rs = new ActiveXObject("ADODB.Recordset");
    var SQL = "select * from Emp_Info";
  rs.Open(SQL, cn);
rs.MoveFirst

while(!rs.eof)
{
    txtid.value = rs(0);
    txtname.value = rs(1);
txtsalary.value = rs(2);
txtcity.value =rs(3);
  rs.movenext;
i=i+1;
 }
rs.Close();
    cn.Close();
    }
    </script>
<h4>EMPLOYEE DETAILS</H4>
    </head>
    <body>
    Employee ID: <input type="text" name="txtid" /> </br> </br>
    Name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="txtname" /> </br> </br>
    Salary:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="txtsalary" /> </br> </br>
City:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="txtcity" /> </br> </br>
    <input type="button" value="submit" onclick="getSubmit()">
    </body>
    </html>
----------------------------------------------------------------------------------
open with internet explorer and enable popups in the browser.
output:




Download zip file

Thursday, 16 March 2017

Difference between HTML and XML



HTML
XML
HTML is an abbreviation for HyperText Markup Language.
XML stands for eXtensible Markup Language.
HTML was designed to display data with focus on how data looks.
XML was designed to be a software and hardware independent tool used to transport and store data, with focus on what data is.
HTML is a markup language itself.
XML provides a framework for defining markup languages.
HTML is a presentation language.
XML is neither a programming language nor a presentation language.
HTML is case insensitive.
XML is case sensitive.
HTML is used for designing a web-page to be rendered on the client side.
XML is used basically to transport data between the application and the database.
HTML has it own predefined tags.
While what makes XML flexible is that custom tags can be defined and the tags are invented by the author of the XML document.
HTML is not strict if the user does not use the closing tags.
XML makes it mandatory for the user the close each tag that has been used.
HTML does not preserve white space.
XML preserves white space.
HTML is about displaying data,hence static.
XML is about carrying information,hence dynamic.

Friday, 6 January 2017

XHTML



What Is XHTML?
  • XHTML stands for EXtensible HyperText Markup Language
  • XHTML is almost identical to HTML
  • XHTML is stricter than HTML
  • XHTML is HTML defined as an XML application
  • XHTML is supported by all major browsers

Why XHTML?
Many pages on the internet contain "bad" HTML.
This HTML code works fine in most browsers (even if it does not follow the HTML rules):
<html>
<head>
  
<title>This is bad HTML</title>

<body>
  
<h1>Bad HTML
  
<p>This is a paragraph
</body>
Today's market consists of different browser technologies. Some browsers run on computers, and some browsers run on mobile phones or other small devices. Smaller devices often lack the resources or power to interpret "bad" markup.
XML is a markup language where documents must be marked up correctly (be "well-formed").
By combining the strengths of HTML and XML, XHTML was developed.
XHTML is HTML redesigned as XML.

The Most Important Differences from HTML:
Document Structure
  • XHTML DOCTYPE is mandatory
  • The xmlns attribute in <html> is mandatory
  • <html>, <head>, <title>, and <body> are mandatory
XHTML Elements
  • XHTML elements must be properly nested
  • XHTML elements must always be closed
  • XHTML elements must be in lowercase
  • XHTML documents must have one root element
XHTML Attributes
  • Attribute names must be in lower case
  • Attribute values must be quoted
  • Attribute minimization is forbidden

<!DOCTYPE ....> Is Mandatory
An XHTML document must have an XHTML DOCTYPE declaration.
A complete list of all the XHTML Doctypes is found in our HTML Tags Reference.
The <html>, <head>, <title>, and <body> elements must also be present, and the xmlns attribute in <html> must specify the xml namespace for the document.
This example shows an XHTML document with a minimum of required tags:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
  
<title>Title of document</title>
</head>

<body>
  some content
</body>

</html>

XHTML Elements Must Be Properly Nested
In HTML, some elements can be improperly nested within each other, like this:
<b><i>This text is bold and italic</b></i>
In XHTML, all elements must be properly nested within each other, like this:
<b><i>This text is bold and italic</i></b>

XHTML Elements Must Always Be Closed
This is wrong:
<p>This is a paragraph
<p>This is another paragraph
This is correct:
<p>This is a paragraph</p>
<p>This is another paragraph</p>

Empty Elements Must Also Be Closed
This is wrong:
A break: <br>
A horizontal rule: 
<hr>
An image: 
<img src="happy.gif" alt="Happy face">
This is correct:
A break: <br />
A horizontal rule: 
<hr />
An image: 
<img src="happy.gif" alt="Happy face" />

XHTML Elements Must Be In Lower Case
This is wrong:
<BODY>
<P>This is a paragraph</P>
</BODY>
This is correct:
<body>
<p>This is a paragraph</p>
</body>

XHTML Attribute Names Must Be In Lower Case
This is wrong:
<table WIDTH="100%">
This is correct:
<table width="100%">

Attribute Values Must Be Quoted
This is wrong:
<table width=100%>
This is correct:
<table width="100%">

Attribute Minimization Is Forbidden
Wrong:
<input type="checkbox" name="vehicle" value="car" checked />
Correct:
<input type="checkbox" name="vehicle" value="car" checked="checked" />
Wrong:
<input type="text" name="lastname" disabled />
Correct:
<input type="text" name="lastname" disabled="disabled" />

How to Convert from HTML to XHTML
  1. Add an XHTML <!DOCTYPE> to the first line of every page
  2. Add an xmlns attribute to the html element of every page
  3. Change all element names to lowercase
  4. Close all empty elements
  5. Change all attribute names to lowercase
  6. Quote all attribute values

Oracle Reserved Words

Oracle  Reserved Words The following words are reserved by Oracle. That is, they have a special meaning to Oracle and so cannot be redefi...