internet computing programs collection

22
HTML Ordered Lists To Create Ordered List: 1. Type the title of the Ordered list. 2. Type <OL>. 3. Type <LI> 4. Type the list item to be included in the list. 5. Repeat steps 3 and 4 for each list item to be added 6. Type </OL> Ordered lists <HTML> <HEAD><TITLE> players listing – ordered </TITLe></HEAD> <BODY> <P> <H1 align=”center”> players selected </H1> <FONT SIZE=15pt”> <OL type=”1”> <LI> Mike Owen <LI> Wayne Rooney <LI> David Beckham </OL> </FONT> </P> </BODY> </HTML>

Upload: mrs-vasanthi-muniasamy

Post on 11-Dec-2015

217 views

Category:

Documents


0 download

DESCRIPTION

Internet Computing Programs Collection

TRANSCRIPT

HTMLOrdered ListsTo Create Ordered List:1. Type the title of the Ordered list.2. Type <OL>.3. Type <LI>4. Type the list item to be included in the list.5. Repeat steps 3 and 4 for each list item to be added6. Type </OL>Ordered lists<HTML><HEAD><TITLE> players listing – ordered </TITLe></HEAD><BODY><P> <H1 align=”center”> players selected </H1><FONT SIZE=15pt”><OL type=”1”><LI> Mike Owen<LI> Wayne Rooney<LI> David Beckham</OL></FONT></P> </BODY> </HTML>

Unordered list<HTML><HEAD><TITLE> players listing – unordered </TITLE></HEAD><BODY><P><H1 align=”center”> Players selected </H1><FONT SIZE=”15pt”><UL TYPE=”square”><LI> Mike Owen<LI> Wayne Rooney<LI> David Beckham</UL></FONT></P></BODY></HTML>

Definition list

<HTML><HEAD><TITLE> Mushrooms – Definition</TITLE></HEAD><BODY><P><H1 align=”center”> Mushrooms </H1><FONT SIZE=”15pt”><DL><DT> <STRONG>Chanterelle</STRONG><DD> Bright yellow mushroom with wavy margin and yellow-orange, forked, thickedged ridges<DT> <STRONG>Chicken Mushroom</STRONG><DD> Single to overlappy clusters offleshy, orange-red to orange-yellow caps.<DT> <STRONG>Kurotake</STRONG><DD> Fleshy, gray to brownish or blackish, smooth cap with whitish pores.</DL></FONT></P></BODY></HTML>

Tables in HTML<HTML><HEAD><TITLE> Simple HTML table </TITLE></HEAD><BODY><TABLE BORDER=”5” WIDTH=”40 %”><CAPTION><STRONG>Players and Teams </STRONG></CAPTION><TH><TR><TD> First Name </td> <td> Second Name </td> <td>Team </TD></TR></TH><BODY><TR> <TD> Glenn</TD> <TD> Megrath </TD> <TD> Austraila </TD> </TR><TR> <TD> Irfan </TD><TD> Pathan </TD><TD> India </TD> </TR></TBODY></TABLE></FONT></BODY><HTML>

HTML forms (with a text box, password, radio button and a button)<HTML><HEAD><TITLE> Banking Page – form demo </TITLE></HEAD><BODY text=black><FORM method=”get” action=”demoone.html”><T><B><H2> Deutsche Bank </H2></B></I><LABEL> <H2>A/C NO.</H2> </LABEL><INPUT type=”text” name=”acno”><BR><LABEL> <H2>PIN</H2> </LABEL><INPUT type=password name=”pin”> <BR><LABEL> <H2>BALANCE ENQUIRY</H2> </LABEL><INPUT type =radio name=”enq”> <BR><LABEL> <H2>TRANSACTION STATEMENT </H2></LABEL><INPUT type =radio name=”statement”><BR><INPUT type=BUTTON value=Submit><BR></FORM></BODY></HTML>

Frames and Framesets<HTML><HEAD><TITLE> FRAMES </TITLE></HEAD><FRAMESET rows="33%,*"><FRAME name="f1" src="example3-3.html"><FRAMESET cols="50%,*"><FRAME name "f2" src="example4-3.html"><FRAME name="f3" src="example4-2.html"></FRAMESET></FRAMESET></HTML>

CSS

2. How to repeat a background image only horizontally <html><head><style type="text/css">body{background-image:url('gradient2.png');background-repeat:repeat-x;}

</style></head><body><h1>Hello World!</h1></body></html>

2. Decorate the text <html><head>

<style type="text/css">h1 {text-decoration:overline;}

h2 {text-decoration:line-through;}h3 {text-decoration:underline;}

h4 {text-decoration:blink;}</style></head><body>

<h1>This is heading 1</h1><h2>This is heading 2</h2><h3>This is heading 3</h3><h4>This is heading 4</h4>

<p><b>Note:</b> The "blink" value is not supported in IE, Chrome, or Safari.</p></body></html>

VBSCRIPT

1. Hello World Program

<html> <body><script type="text/vbscript"><!--document.write("Hello World!")--></script></body></html>

2. Assign data to a one-dimensional array:

<html><body><script type="text/vbscript">Dim x(1,1)x(0,0)="Volvo"x(0,1)="BMW"x(1,0)="Apple"x(1,1)="Orange"for i=0 to 1 document.write("<p>") for j=0 to 1 document.write(x(i,j) & "<br />") next document.write("</p>")next</script></body></html>

3. For...Next statement to run a block of code a specified number of times

<html><body><script type="text/vbscript">For i = 0 To 5 document.write("The number is " & i & "<br />")Next</script></body></html>

The counter variable (i) is INCREASED by two, each time the loop repeats

The counter variable (i) is DECREASED by two, each time the loop repeats

You can exit a For...Next statement with the Exit For keyword

For i=2 To 10 Step 2 some codeNext

For i=10 To 2 Step -2 some codeNext

For i=1 To 10 If i=5 Then Exit For some codeNext

4. A For Each...Next loop repeats a block of code for each item in a collection, or for each element of an array.

<html><body><script type="text/vbscript">Dim cars(2)cars(0)="Volvo"cars(1)="Saab"cars(2)="BMW"For Each x In cars document.write(x & "<br />")Next</script></body> </html>

5. If...Then...ElseIf

<html><body><head><script type="text/vbscript">Function greeting()i=hour(time)If i = 10 Then document.write("Just started...!")ElseIf i = 11 then document.write("Hungry!")ElseIf i = 12 then document.write("Ah, lunch-time!")ElseIf i = 16 then document.write("Time to go home!")Else

document.write("Unknown")End IfEnd Function</script></head><body onload="greeting()"></body></html>

6. Display Date and Time

<html><body><script type="text/vbscript">document.write("Today's date is " & Date())document.write("<br />")document.write("The time is " & Time())</script></body></html>

7. Remove Leading Trailing Spaces from a String

<html><body><script type="text/vbscript">fname=" Bill "document.write("Hello" & Trim(fname) & "Gates<br />")document.write("Hello" & RTrim(fname) & "Gates<br />")document.write("Hello" & LTrim(fname) & "Gates<br />")</script></body></html>

8. Reverse a String

<html><body><script type="text/vbscript">sometext = "Hello Everyone!"document.write(StrReverse(sometext))</script></body></html>

9. Round a number<html><body><script type="text/vbscript">i = 48.66776677j = 48.3333333document.write(Round(i))document.write("<br />")document.write(Round(j))</script></body></html>

10. Return a random number between 0-99

<html><body><script type="text/vbscript">Randomize()randomNumber=Int(100 * Rnd())document.write("A random number: <b>" & randomNumber & "</b>")</script></body></html>

11. Return a specified number of characters from the left or right side of a string<html><body><script type="text/vbscript">sometext="Welcome to our Web Site!!"document.write(Left(sometext,5))document.write("<br />")document.write(Right(sometext,5))</script></body></html>

12. Return a specified number of characters from a string

<html><body>

<script type="text/vbscript">sometext="Welcome to our Web Site!!"

document.write(Mid(sometext, 9, 2))</script></body></html>

JAVASCRIPTThe syntax of JavaScript as follows:

<script type=”text/javascript”>

<!-- script code here! -->

</script>

First JavaScript program

<html>

<head><title>MY SCRIPT</title>

</head>

<body>

<font size="5">

<script type="text/javascript">

document.write("Hello World!");

</script>

<p><b>THIS IS MY JAVA SCRIPT TEST PAGE</b></p>

</font>

</body>

</html>

1. A simple program to explain variables

<html>

<head>

<title>

An Addition Program

</title>

</head>

<script type =”text/javascript”>

var firstno,secondno,number1,number2,sum;

//reads first number from user as a string

firstno= window.prompt(“enter first integer”,”0”);

secondno= window.prompt(“enter second integer”,”0”);

//converts numbers from strings to integers

number1=parseInt(firstno);

number2=parseInt(secondno);

sum=number1+number2;

//display the result

document.writeln(“<h1>sum:” +sum +</h1>”);

</script>

</head>

<body>

<p> Click refresh or reload to run the script again</p>

</body>

</html>

2. Handling Events in JavaScript, an alert window

<HTML>

<HEAD><TITLE>Handling Events Example</TITLE></HEAD>

<BODY>

<H1>Handling Events in JavaScript</H1>

<FORM>

<INPUT TYPE="button" VALUE="Click me"

onClick="alert('You clicked me')" >

</FORM>

<div style="display: block; font-family: Verdana, Geneva, Arial; fontsize:10px">

This program uses JavaScript’s alert window!

</div>

</BODY>

</HTML>

3. Using for loop

<HTML>

<HEAD><TITLE>Computing Factorials</TITLE></HEAD>

<BODY>

<H1>Another Example of JavaScript</H1>

<SCRIPT LANGUAGE="JavaScript">

document.write("<H1>Factorial Table</H1>");

for ( i = 1, fact = 1; i < 10; i++, fact = fact * i) {

document.write(i + "! = " + fact);

document.write("<BR>");

}

</SCRIPT>

<div style="display: block; font-family: Verdana, Geneva, Arial; fontsize: 10px">

This program demonstrates the usage of for loop in calculating

Factorial of numbers from 1 to 9

</div>

</BODY>

</HTML>

4. Operators Example

<html>

<body>

<script type="text/javascript">

<!--

var two = 2

var ten = 10

var linebreak = "<br />"

document.write("two plus ten = ")

result = two + ten

document.write(result)

document.write(linebreak)

document.write("ten * ten = ")

result = ten * ten

document.write(result)

document.write(linebreak)

document.write("ten / two = ")

result = ten / two

document.write(result)

//-->

</script>

</body>

</html>

5. Program to display square of numbers from 1 to 10:

<html>

<head>

<title>script user function </title>

<script type=”text/ JavaScript”>

document.write(“ <h1> square the numbers from 1 to 10 </h1>”);

for (var x=1; x<=10;++x)

document.writeIn(“the square of” + x + ” is” + square (x) + ”<br/>”);

function square(y)

{

return y*y;

}

</script></head><body>

<p>click refresh </p>

</body></html>

6. Displaying system date and time

<HTML><HEAD><TITLE>Example using new</TITLE>

<SCRIPT LANGUAGE=JavaScript>

function outputDate() {

var d = new Date(); //creates today's date and time

document.write(d.toLocaleString()); } // converts a date to a string

</SCRIPT></HEAD>

<BODY>

<H1>The date and time are</H1>

<SCRIPT LANGUAGE=JavaScript>

outputDate();

</SCRIPT>

<div style="display: block; font-family: Verdana, Geneva, Arial; fontsize:

10px">

This program illustrates use of user defined function

</div>

</BODY>

</HTML>

7. Using Date object

<HTML>

<HEAD>

<TITLE>Using the Date Object</TITLE>

<SCRIPT LANGUAGE="JavaScript">

function Clock(hours, minutes, seconds) {

this.hours = hours; this.minutes = minutes; this.seconds = seconds;

}

function DisplayClock(Clock) {

var clockdisp=Clock.hours + ":" + Clock.minutes + ":" + Clock.seconds;

document.write("<BR>The time is:" + clockdisp);

}

</SCRIPT>

</HEAD>

<BODY>

<HR>

<SCRIPT LANGUAGE="JavaScript">

var timenow = new Date;

document.write(timenow);

thisClock = new

Clock(timenow.getHours(),timenow.getMinutes(),timenow.getSeconds()

);

Client and Serverside Scripting 131

DisplayClock(thisClock);

</SCRIPT>

<br>

<a href="../ ">Return to Main Page</a>

</BODY>

</HTML>

8. Function to accept and return the product of two parameters

<html>

<head>

<script type="text/javascript">

function product(a,b)

{

return a*b;

}

</script>

</head>

<body>

<script type="text/javascript">

document.write(product(4,3));

</script>

</body>

</html>

JSPThe following example will declare two variables; one string used to store the name of a website and an integer called counter that displays the number of times the page has been accessed. There is also a private method declared to increment the counter. The website name and counter value are displayed.

<HTML>

<HEAD>

<TITLE> JSP Example 2</TITLE>

</HEAD>

<BODY> JSP Example 2

<BR>

<%!

String sitename = “boiap.ac.in”;

int counter = 0;

private void increment Counter()

{

counter ++;

}

%>

Website of the day is

<%= sitename %>

<BR>

page accessed

<%= counter %>

</BODY></HTML>