Introduction of javascript

  • 163 views
Uploaded on

 

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
163
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
2
Comments
0
Likes
1

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. INTRODUCTION OF JAVASCRIPTWhat is JavaScript?JavaScript (sometimes abbreviated JS) is a prototype-based scripting language thatis dynamic, weakly typed and has first-class functions. It is a multi-paradigm language,supporting object-oriented, imperative, and functional programming styles. JavaScript isan implementation of the ECMAScript language standard and is typically used to enableprogrammatic access to computational objects within a host environment. JavaScript is aprogramming language used to make web pages interactive. It runs on your visitorscomputer and doesnt require constant downloads from your website. JavaScript is oftenused to create polls and quizzes. It is the standard language used in web pages, but it isalso widely used by desktop apps, mobile phone apps, and internet servers.Why we use JavaScript?JavaScript is not specifically HTML related, but interacts with HTML and DHTML whenused in a browser. Its a more traditional programming language, in that you can write aseries of instructions to compute what kinds of actions should be taken based on variousconditions, repeat things a variable number of times, and just generally take more complexand sophisticated actions. Small applications and games have been written entirely inJavaScript.The line between DHTML and JavaScript can sometimes get blurry, but a rule of thumb Iuse is simple: DHTML is about the web page, period. The items on a web page, the eventsthat a web page might want to act on (like moving your mouse over text), and the resultingchanges to the web page that you might want to have happen resulting from those events(like changing the color of text). JavaScript, however, is really web, and HTML,independent. It adds programming things like loops, and variables and functions. You couldwrite a small program to calculate Pi in JavaScript, and then perhaps use DHTML to dosomething interesting on the web page with it.
  • 2. What is the purpose of JavaScript?Functions allow us to remove these statements from all of the places that they are neededand define them just once. We then “call” the function from each of the places where weneed those statements to run. This makes maintaining the code easier as we only have oneplace where the particular series of statements occurs rather than repetitions of thesame code. Any changes to that one block will automatically apply to each place where thefunction is called.Using functions also allows us to modularize our approach to writing thecode. This means that we can break up the processing into sections and not concernourselves with how all of the processing needs to work all at the same time. When we arecoding the function we need only concern ourselves with how the function needs to becoded in order to perform its intended task.JavaScript program:<!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><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>zoya</title><script type="text/javascript">functionabc(){ var a=document.getElementById(un).value; if(a=="") {alert("Must be enter name");
  • 3. return false; } var p=document.getElementById(pwd).value; if(p=="") { alert("must enter pasword"); return false; } if(p.length<8) { alert("password too Short"); return false; } if(p.length>=14) { alert("password too long"); return false; } var e=document.getElementById(em).value; em.indexof("@") if(e==-1) { alert("must enter @");
  • 4. return false; } em.indexof(".") if(e==-1) { alert("must enter ."); return false; }}</script></head><body><form>Username:<input type="text" name="uname" id="un"/><br/><br/>Password:<input type="password" id="pwd"/><br/>
  • 5. <br/>E-mail:<input type="text" name="mal" id="em"/><br/><br/><input type="submit" value="login" onclick="return abc()" /></form></body></html>