Home Javascript Writing Simple Java Script Program


Share on Google+Share on Google+

Writing Simple Java Script Program

In this article you learn the basics of JavaScript and create your first JavaScript program.

Writing Simple Java Script Program


In this article you learn the basics of JavaScript and create your first JavaScript program.

Creating your first JavaScript Program

In the last lesson you learned how to create simple java script program. To run the program open the html file in any browser and click on the "Run Java Script First Program". The will display the message box. Here is the screen shot of the browser.

Test JavaScript program from here.

Here is the code of JavaScript program:

<title>First Java Script</title>
<script language="JavaScript">
function sayhello(){
alert("Welcome to JavaScript World!");


<p><b>Click the following link to run your first java script example</b></p>
<p><a href="javascript:sayhello()">Run JavaScript First Program</a></p>


Following is the JavaScript program that will show the message:

<script language="JavaScript">
function sayhello(){
alert("Welcome to JavaScript World!");

The alert() function of the java script displays message.




If you enjoyed this post then why not add us on Google+? Add us to your Circles

Liked it!  Share this Tutorial

Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: June 11, 2009

Ask Questions?    Discuss: Writing Simple Java Script Program   View All Comments

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
padam giri
April 11, 2011

i want to learn this program, to create website.since i am not the student of IT again than i have a desire to learn.
prasanna venkat
April 15, 2011

i'am in need of a simple java program for for creation of lists. . both single and double. . can you please mail me the program as soon as possible. .
August 22, 2011
plz check and mail me result

<html> <head> <script text="javascript"> function split1() { var name=document.getElementById("txtname") var pos1,pos2,fname="",mname="",lname=""; pos1=name.indexOf(" "); name=name.toLowerCase(); if(pos1>-1) { pos2=name.indexOf(" ",pos1+1); if(pos2>-1) { fname=name.substring(0,pos1); mname=name.substring(pos1+1,pos2); lname=name.substring(pos2+1); else { fname=name; }} fname=fname.length>0?fname.charAt(0).UpperCase()+fname.substr(1):""; mname=mname.length>0?mname.charAt(0).UpperCase()+mname.substr(1):""; lname=lname.length>0?lname.charAt(0).UpperCase()+lname.substr(1):""; document.getElementById("fname").innerHTML=fname; document.getElementById("mname").innerHTML=mname; document.getElementById("lname").innerHTML=lname; } function split2() { var name=document.getElementById("txtname").value; var arr=name.split(" "); var fname=arr.length>0?arr[0]:""; var mname=arr.length>1?arr[1]:""; var lname=arr.length>2?arr[2]:""; document.getElementById("fname").innerHTML=fname; document.getElementById("mname").innerHTML=mname; document.getElementById("lname").innerHTML=lname; } </script> </head> <body> <table align="center"> <tr> <th> Enter any number </th> <td> <input id="txtname" /> </td> </tr> <tr> <td><input type="button" value="split1" onclick="split1()" /></td> <td><input type="button" value="split2" onclick="split2()" /></td> </tr> <tr><td>First Name</td> <td id="fname"></td> </tr> <tr><td>Middle Name</td> <td id="mname"></td> </tr> <tr><td>Last Name</td> <td id="lname"></td> </tr> </table> </body> </html>
ankita singh
August 24, 2011
javascript alert

alert("hello"); shows different pop up box in mozilla and something else in internet explorer.Why so? Do I need to change my netbeans browser setting (if yes, how to).
September 6, 2011
i want to program now itself..............

java script to display a message "hi good morning to u" when a page is loaded and display a message "THANKS TO VISIT OUR WEBPAGE" when a page is unloaded.......
December 23, 2011

this code is very useful to me..thanks.
January 27, 2012

January 27, 2012
very useful

this website very useful for me to learn the jsp from base by practical&theoritcal way
January 31, 2012

February 4, 2012
javascript programs

how to create javascript program for a general store with save option
February 13, 2012
give me some jsp related projects

nice explanation
Hanumant Bandgar
March 2, 2012
Web Development

Its more useful for the Teaching.
March 10, 2012
javascript want to any new produced

usually of simple logic contents
March 13, 2012
were is porgram

program downloaded
June 15, 2012
writting program in javascript

A sales manager wants to know the percentage increase in sales for 2011 compared with 2010. Convert percentages to the standard format(multiplying the decimal amount by 100) and display them with two decimal places. Using Javascript, write a program that implements the sales increase Percentage algorithm.
June 28, 2012

December 27, 2012

hi, can anybody can say that how to convert this following code into javascript.? <script> $(function () { $("#table1 tbody.rep-drag").sortable({ revert: true }); $("#table1 tbody.rep-drag").disableSelection(); }); </script> where table1 is id for class and rep-drag for class for body.
Herad Majhi
December 17, 2012
Relation of number

how to code java script programme?
shraddha dwivedi
September 20, 2012
opening steps of java script

how to open& run java script?
September 21, 2012
java script

there are two error in simple java script program