Hi Clement,
Go through this below code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 4.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>JavaScript Variables</title>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="default.css" rel="stylesheet" type="text/css" />
<link href="homeoutside/formozilla.css" rel="stylesheet" type="text/css" />
<link href="homeoutside/forie.css" rel="stylesheet" type="text/css" />
<link href="homeoutside/forie7new.css" rel="stylesheet" type="text/css" />
<!-- To Desplay month date and time -->
<script type="text/javascript">
tday =new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
tmonth=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
function GetClock(){
d = new Date();
nday = d.getDay();
nmonth = d.getMonth();
ndate = d.getDate();
nyear = d.getYear();
nhour = d.getHours();
nmin = d.getMinutes();
nsec = d.getSeconds();
if(nyear<1000) nyear=nyear+1900;
if(nhour == 0) {ap = " AM";nhour = 12;}
else if(nhour <= 11) {ap = " AM";}
else if(nhour == 12) {ap = " PM";}
else if(nhour >= 13) {ap = " PM";nhour -= 12;}
if(nmin <= 9) {nmin = "0" +nmin;}
if(nsec <= 9) {nsec = "0" +nsec;}
document.getElementById('clockbox').innerHTML=""+tday[nday]+", "+tmonth[nmonth]+" "+ndate+", "+nyear+" "+nhour+":"+nmin+":"+nsec+ap+"";
setTimeout("GetClock()", 1000);
}
window.onload=GetClock;
</script>
</head>
<body>
<div id="page">
<div id="banner">
</div>
<div id="saturday">
<ul>
<li><a href="home.html" class="current"><span>Home</span></a></li>
<li><a href="string.html"><span>String Functions</span></a></li>
<li><a href="calculatore.html" ><span>Calculator</span></a></li>
<li><a href="palin.html"><span>Palindrome</span></a></li>
</ul>
</div>
<div id="content">
<h1>Check a string is palindrome..</h1>
<br />
<script type="text/javascript" language="JavaScript">
<!--
function reverseString(the_word){
// reverseString takes a string and returns the reverse string
var rString = "";
var alen = the_word.length;
for (var i = alen ; i > 0 ; i--){
rString += the_word.charAt(i-1)
};
return rString ;
}
function palindrome(the_word){
// palindrome takes a string and returns true if and only if the string
// is a palindrome
return (the_word == reverseString(the_word));
}
function doCodeForPalin(){
// This code is the code to be executed on clicking the ``do it'' button
var aStr = document.palinForm.inputWord.value;
document.palinForm.outputWord.value = reverseString(aStr);
document.palinForm.isPalin.value = palindrome(aStr);
return true;
}
//-->
</script>
</head>
<body bgcolor="white">
<form name="palinForm">
<p>Check if the Palidrome is a <strong>PERFECT</strong> Palindrom
<br/>
<p>Enter your word here: <input type="text" name="inputWord"><br><br />
<input type="button" name="doIt" value="Is it Palindrome?" onclick="doCodeForPalin();">
<input type="text" name="isPalin" value=""><br><br />
Your Input Reversed:
<input type="text" name="outputWord"><br/><br />
</p>
</form>
</body></center>
<p>
<a href="home.html"> << Back To Home</a>
</p>
<p>Note:<small>This is working for number also.</small></p>
</div>
</div>
<div id="footer">
<p>Copy Right <big>©</big> 2011, Designed by<a href=""><em>OpenClubAnandhu.</em></a>
</div>
</body>
</html>
Feb 23, 2011