Latest Movie :
Recent Movies

PHP and MySQL Scripts and Tutorials Download

{[['']]}

Creating a website using PHP Includes

Back to what we were doing, the layout of our page will be like:-

Step One A good rule is to keep all files which are related to a particular website in the same folder. This prevents any dead links or linking errors which may creep in later on when the website gets quite large. This applies to all websites you create and not just this tutorial. Another good tip which is worth remembering is to keep all filenames you create for pages in lowercase.

Read more...
{[['']]}

Design Layout Form Login

{[['']]}

Top Search Enging



{[['']]}

Cut & Paste JavaScript Image Clock


Description: This is a compact JavaScript image clock that's updated live every second. It comes with a default image pack for the interface, though you can easily specify you own "digits" images instead inside the script.
Download Source Code
{[['']]}

Live Clock JavaScript

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Time</title>
</head>

<body>

<body>
<script>

var Digital=new Date()


var hours=Digital.getHours()
var minutes=Digital.getMinutes()
var seconds=Digital.getSeconds()
var dn="AM"
if (hours>12){
dn="PM"
hours=hours-12
}
if (hours==0)
hours=12
if (minutes<=9)

minutes="0"+minutes
if (seconds<=9)
seconds="0"+seconds
var ctime="<b><font face='Verdana' color='#8000FF'>"+hours+":"+minutes+":"+seconds+" "+dn+"</font></b>"
document.write(ctime);
//-->
</script>
</body>
</html>

Download Source Code -> Live text Clock JavaScript

Download Example Code -> Data and Clock on Status bar

Source code Calendar

Download -> I have been alive for...

Free Download : Game -> Ouths and Crosses

{[['']]}

JavaScript while Loop statement

{[['']]}

Form Calculator in JavaScript

This Form Calculator in JavaScript with HTML

Download this Source Code


JavaScript document.getElementById<script type="text/javascript">
function notEmpty()
{
var myTextField = document.getElementById('myText');
if(myTextField.value != "")
alert("You entered: " + myTextField.value)
else
alert("Would you please enter some text?")
}
</script>

<input type='text' id='myText' />
<input type='button' onclick='notEmpty()' value='Form Checker' />
{[['']]}

JavaScript Functions

What's a Function?
A function is a piece of code that sits dormant until it is referenced or called upon to do its "function". In addition to controllable execution, functions are also a great time saver for doing repetitive tasks.

To create a function, type the function keyword followed by a name for the function, followed by an opening, then a closing, parentheses, followed by an opening curly bracket “{“ and ending with a closing curly bracket “}”. Here is the syntax for creating a function:

function name(){}

Read more...

{[['']]}

For Loop Statement

The for loop is used when you know in advance how many times the script should run.

for (variable=startvalue;variable<=endvalue;variable=variable+increment)

{

code to be executed

}

Ex1:

<html>

<body><script type="text/javascript">

var i=0;

for (i=0;i<=5;i++)

{

document.write("The number is " + i);

document.write("<br />");

}

</script>

</body>

</html>

Ex2:

<script type="text/javascript">

<!--

var count;

document.write("Starting Loop" + "<br />");

for(count = 0; count < 10; count++){

document.write("Current Count : " + count );

document.write("<br />");

}

document.write("Loop stopped!");

//-->

</script>

Ex3:

For example, continue can be employed to display only the even numbers
between 1 to 20, skipping the odd numbers.

<script>

var msg = "";
for (var x = 0; x <=20; x++)
{
if (x%2)
{
continue;
}

msg = msg + x + "\n";

}

alert(msg);

</script>

Output:

0 2 4 6 8 10 12 14 16 18 20

<script>
var msg = "";
for (var x = 0; x <=20; x++)
{
if (x%2)
msg = msg + x + "\n";

}

alert(msg);
</script>

Output:

1 3 5 7 9 11 13 15 17 19

Similarly, break is employed to stop loop iterations completely.

Ex:

<script>
var msg = "";
var t = 1;

while (t <= 10)

{

if (t == 8)

{
break;
}
msg = msg + t + "\n";
t++;
}
alert(msg);

</script>

Output:
1 2 3 4 5 6 7

Assignment

1- In the code below, which numbers are displayed in the alert box?

<script>

var msg = "";
for (var x = 0; x < 10; x++)
{
if (x == 5 || x == 7)
{
continue;
}

msg = msg + x + "\n";
}

alert(msg);

</script>

2- How can you display the odd numbers between 1 to 20 WITHOUT

the use of continue?

Possible Answers

0, 1, 2, 3, 4, 6, 8 and 9.

var msg = "";

for (var x = 1; x <= 20; x = x + 2)

{
msg = msg + x + "\n";
}
alert(msg);

OR

var msg = "";

var x = 1;
while (x <= 20)
{
msg = msg + x + "\n";
x = x + 2;
}
alert(msg);

{[['']]}

While Loop Statement

The JavaScript while loop is much simpler than the for loop. It consists of a condition and the statement block.

Syntax:

while (condition)
{
...statements...

}

Ex1:

<script>

var msg = "";
var x = 1;
while (x <= 10)
{
msg = msg + x + "\n";
x++;

}

alert(msg);</script>

Ex2:

<script>

var msg = "";
var x = 1;
var res = 0;
while (x <= 10)

{

res = 12 * x;
msg = msg + "12 X " + x + " = " + res + "\n";
x++;

}
alert(msg)


</script>

Output: n/a

{[['']]}

The Do While loop

You can consider the do-while loop as a modified version of the while loop. Here, the condition is placed at the end of the loop and hence, the loop is executed at least once.

Ex3:

<script>

var x = 20;

do
{

alert("The number is " + x);
x++;
}
while (x <= 10);
</script>

Ex4:

<script>
var x = 20;
do
{
alert("The number is " + x);
x++;
}
while (x <= 30);
</script>

Assignment

Ex5:

<script>
var num=0;
while (num <= 30)
{
document.write(num+"<br>");
num = num + 3;
}
</script>

1- If the value of variable num is 20, how many times will the following while loop be execute

Ex6:
2- How many times is the while loop executed in the following code?

<script>
var b = 45;
var a = 14;
while (a <= 20)
{
document.write("All is well with me");
b = b + 5;
}
document.write("Once time");
</script>

3- If the condition evaluates to 'false', how many times is the do-while loop executed and why?

Possible Answers

Four times

Infinite times since there is no update statement for variable a inside the while loop.

Once, because the condition is present at the end of the loop.

{[['']]}

Switch Statement

<script>

var day="Friday";

switch(day){

case "Monday" : document.write("First Day"); break; case "Wednesday" : document.write("Four Day"); break;

case "Friday" : document.write("Happy Day"); break;

case "Sunday" : document.write("Weekend Day"); break;


default:document.write("Day Off");break;

}


</script>

{[['']]}

IF Statements

IF Statement
One Condition

var day="Friday";
if(day=="Friday"){
document.write("Happy Day");
}
--------------------------------
IF / Else Statement
Two Condition

var day="Friday";
if(day=="Friday"){
document.write("Happy Day");
}
else{
document.write("Bad Day");
}
-------------------------------------
IF / Else Statement
Many Condition

var day="Friday";
if(day=="Monday"){
document.write("First Day");
}
else if(day=="Wednesday"){
document.write("Four Day");
}else if(day=="Friday"){
document.write("Happy Day");
}
else if(day=="Sunday"){
document.write("Weekend Day");
}else{
document.write("Day Off");
}
{[['']]}

Create Form E-mail with JavaScript

{[['']]}

Calculator, For Statement

Write Code: javascript

<script type="text/javascript">

var total = 0;

var even = 0;

for ( x = 1, y = 1; x <= 100; x++, y++ ) {

if ( ( y % 2 ) == 0 ) {

even = even + y;

}

total = total + x;

}

document.write ( "The total sum: " + total + "<br>");

document.write ( "The sum of even values: " + even );

</script>

</head>

<body>

Output:
The total sum: 5050
The sum of even values: 2550
{[['']]}

JavaScript : Operand


<script language="javascript">

function operand(){

var fr = document.operator;

fr.txtr.value=parseInt(fr.txt1.value)+parseInt(fr.txt2.value);

}

</script>

<body>

<form name="operator">
<fieldset class="cut">
Operand 1:<br />
<input type="text" name="txt1" size="30" /><br />
Operand 2:<br />
<input type="text" name="txt2" size="30" /> <br />

Result :<br />

<input type="text" name="txtr" size="30" />

<input type="hidden" name="txth" size="30" />

</fieldset>
<fieldset class="cut">
<input type="button" name="btns" value=" + " onclick="operand()" />
<br />
</fieldset>
</form>
</body>

{[['']]}

JavaScript : Calculator


<script>
function sum()
{
var a=document.getElementById('t1').value;
var b=document.getElementById('t2').value;
document.getElementById('rs').innerHTML = eval(a) + eval(b);
}
</script>
.............
Result is :
<div id="rs"></div>

Download
{[['']]}
 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. isophal.com - All Rights Reserved
Template Created by Creating Website Published by Mas Template
Proudly powered by Blogger