Thursday 21 November 2013

java script

 Java Script



What Is JavaScript?

An explanation of exactly what JavaScript is has to begin with Java. Java is a new kind of Web programming language developed by Sun Microsystems. A Java program, or applet, can be loaded by an HTML page and executed by the Java Interpreter, which is embedded into the browser.
Java is a complex language, similar to C++. Java is object-oriented and has a wide variety of capabilities; it's also a bit confusing and requires an extensive development cycle. That's where JavaScript comes in.
JavaScript is one of a new breed of Web languages called scripting languages. These are simple languages that can be used to add extra features to an otherwise dull and dreary Web page. While Java is intended for programmers, scripting languages make it easy for nonprogrammers to improve a Web page.
JavaScript was originally developed by Netscape Corporation for use in its browser, Netscape Navigator. It includes a convenient syntax, flexible variable types, and easy access to the browser's features. It can run on the browser without being compiled; the source code can be placed directly into a Web page.
You can program in JavaScript easily; no development tools or compilers are required. You can use the same editor you use to create HTML documents to create JavaScript, and it executes directly on the browser (currently, Netscape or Microsoft Internet Explorer).
JavaScript was originally called LiveScript, and was a proprietary feature of the Netscape browser. JavaScript has now been approved by Sun, the developer of Java, as a scripting language to complement Java. Support has also been announced by several other companies.
Although useful in working with Java, you'll find that JavaScript can be quite useful in its own right. It can work directly with HTML elements in a Web page, something Java can't handle. It is also simple to use, and you can do quite a bit with just a few JavaScript statements. You'll see examples of the power of JavaScript throughout this guide.

History of JavaScript

As mentioned before, the history of JavaScript begins with Java. Java was originally developed by Sun Microsystems for use in "real-time embedded systems"-in other words, consumer electronics. Java has now become the de facto standard for advanced Internet programming, but you may still see it running your cellular phone someday.
Java was designed to operate on a virtual machine-a piece of software that interprets the Java code and acts on it as if it were a computer in itself. The virtual machine was designed to be simple so it could be implemented easily in a device. This is what makes it easy to implement in Web browsers.
Java was originally supported only by HotJava, an experimental Web browser developed by Sun for that purpose. Recognizing its potential, Netscape integrated it into its Web browser, Netscape Navigator. Because Navigator is the most popular browser, this greatly increased the publicity for Java.
In 1995, Java became the hottest new buzzword for the Internet, but few people actually knew how to program it. Netscape Communications recognized the need for a simple, clear language for Web pages and introduced LiveScript, the first of the Web scripting languages.
LiveScript had a syntax based on Java, but was more concise and easier to learn. It was also a directly interpreted language rather than a compiled language like Java. Netscape built LiveScript into the beta versions of Netscape Navigator. Support for LiveScript began with version 2.0b1, released in June 1995.
Later in 1995, Netscape reached an agreement with Sun. Sun also recognized that a simple scripting language was a good idea, so they officially endorsed LiveScript. Thus, the connection with Java became official, and the name changed to the one you're familiar with: JavaScript.
At this writing, JavaScript is still being developed and continues to improve. Netscape's support for JavaScript is expected to be finalized by the end of 1996, and other companies-most notably, Microsoft-are rushing to release competing products. Microsoft Internet Explorer (MSIE) 3.0, currently in beta, supports basic JavaScript, along with Microsoft's answer to JavaScript, VBScript.

JavaScript Versus Java

The process of writing a Java applet can be complicated-writing the source code, compiling, and making the applet available on the server. JavaScript provides a much simpler alternative for small projects. The JavaScript source code is interpreted directly by the browser. The source can either be included directly within an HTML page or referenced in a separate file.
Although JavaScript doesn't really have any features that eclipse Java, it adds some conveniences, simplifies programming, and provides better integration with the browser. The key differences include the following (explained in the following sections):
  • JavaScript can be combined directly with HTML.
  • The JavaScript language structure is simpler than that of Java.
  • The JavaScript interpreter is built into a Web browser.
  • JavaScript is supported on more platforms than Java.

Combining JavaScript with HTML

Java applets are compiled and stored on the server as byte codes, but JavaScript programs are simple ASCII text files. You can keep them as separate files or include the JavaScript functions within an HTML page.
The <SCRIPT> tag, an extension of HTML supported by Netscape, enables you to include one or more JavaScript functions in the page. Example 1.1 is a very small JavaScript script embedded directly within HTML. You take a more detailed look at the syntax of these tags later in this chapter.


Example 1.1.  A simple JavaScript program within an HTML document.
<HTML><HEAD> <TITLE>Simple JavaScript Example </TITLE> </HEAD> <BODY> HTML Text goes here. <SCRIPT LANGUAGE="JavaScript"> document.write("Here is  output.") </SCRIPT> </BODY></HTML>


An alternate option called an event handler enables you to specify a JavaScript action that will be performed when an event occurs. For example, a button on the page might have an action performed when it is pressed. This provides a more dynamic method of accessing JavaScript.
Instead of the <SCRIPT> tag, an event handler is added as an attribute to an HTML tag. As an example, the following HTML code defines a link with an event handler: <A HREF="www.netscape.com" onClick="alert('This will take you to Netscape's home page.');">
In this case, the name of the event is onClick. This particular event happens when the user clicks on the link. The JavaScript code to perform when the link is clicked is enclosed within double quotation marks. 

Simplified Language Structure

The limitations of JavaScript also make it much easier for the programmer. The syntax of the JavaScript language is more relaxed than that of Java, and variables (names used to store values) are easier to use. Here are the specifics:
  • The JavaScript language is interpreted rather than compiled. Changing a script is as simple as changing an HTML page.
  • Rather than creating objects and classes, you can do quite a bit by simply accessing existing objects in JavaScript.
  • Variables are loosely typed: You do not need to declare variables before their use, and most conversions (such as numeric to string) are handled automatically.
  • Event handlers enable a JavaScript function to execute whenever an action is performed on part of the HTML document. For example, a form's input field can be checked for certain values whenever it is modified.

Web Browser Integration

JavaScript is an object-oriented language. This simply means that it can use objects. An object is a more complicated version of a variable. It can store multiple values and can also include actual JavaScript code. You can create your own objects to represent just about anything.
JavaScript also includes objects that enable you to access features of the browser directly. These objects represent actual elements of the browser and the Web page, such as windows, documents, frames, forms, links, and anchors.
You can access information about the links, anchors, and form elements in the current page. You can also control the browser with JavaScript. For example, it's possible to include a "back" button on your page that will send the user back to the previous page-just like the browser's back-arrow button.
Of course, when I say "browser" here, I'm talking about browsers that support JavaScript. Netscape Navigator began supporting it in version 2.0b1, and at this writing, version 3.0b6 is the latest version. It will also be supported by Microsoft Internet Explorer.

Monday 18 November 2013

Sql Programing

Programming in SQL Server




Program 1.

 

begin 
 
print ' welcome to SQL Programming ‘
print ' SQL Server ‘ 

 
end


Program 2.

 

begin

declare @a int
declare @b int
declare @c int

set @a=67
set @b = 99
set @c=@a+@b

print @a
print @b
print@c

 print ' first program '

end


Program 3.

 

declare

@p int,@n decimal(5,2),@r decimal(5,2), @si decimal(7,2)

begin

set @p=10000
set @n=15
set @r=7.5
set @si=(@p*@n*@r)/100

print ' simple interest : ' + convert(varchar,@si)

end


 Program 4.

 

declare

@a int,@b int,@c int

begin

set @a=50
set @b=120
set @c=35

if @a>@b and @a>@c

print ' a is big'

else if @b>@c

print ' b is big'

else

print ' c is big'

end

 Program 5.

 

declare

@a int

begin

set @a=1

while (@a<=5)

begin

print @a

set @a=@a+1

end

 


Wednesday 13 November 2013

Palindrome


Palindrome Problem


A palindrome is a word that reads the same both forwards and backwards.
Examples: anna, nitalarbralatin, amanaplanacanalpanama.

Program -

#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
void main()
{char a[20],b[20];
cout<<"enter the string"<<endl;
gets(a);
strcpy(b,a);
strrev(b);
if(strcmpi(a,b)==0)
cout<<"palindrome"<<endl;
else
cout<<"nay"<<endl;
getch();
}

Tuesday 12 November 2013

SQL Select Command

SQL STATEMENT


SELECT Statement

The SELECT statement is used to select data from a database.
The result is stored in a result table, called the result-set.

 Syntax -

SELECT column_name(s)
FROM table_name
and
SELECT * FROM table_name
 Note: SQL is not case sensitive. SELECT is the same as select.

 SELECT DISTINCT Statement


In a table, some of the columns may contain duplicate values. This is not a problem, however, sometimes you will want to list only the different (distinct) values in a table.
The DISTINCT keyword can be used to return only distinct (different) values.

 Syntax -

SELECT DISTINCT column_name(s)
FROM table_name

The WHERE Clause

The WHERE clause is used to extract only those records that fulfill a specified criterion.

Syntax -

SELECT column_name(s)
FROM table_name
WHERE column_name operator value

The ORDER BY Keyword

The ORDER BY keyword is used to sort the result-set by a specified column.
The ORDER BY keyword sort the records in ascending order by default.
If you want to sort the records in a descending order, you can use the DESC keyword.

 Syntax -

SELECT column_name(s)
FROM table_name
ORDER BY column_name(s) ASC|DESC



Artificial Intelligence (AI)

  Artificial Intelligence (AI) The Power and Potential of Artificial Intelligence Artificial Intelligence (AI) is revolutionizing the world ...