Forum : Please i need urgent assistance on the calculation and paindrorme...my code is not working
Brief description  about Online courses   join in Online courses
View Clement  Osei Tutu 's Profile

Please i need urgent assistance on the calculation and paindrorme...my code is not working

Dear sir,
Help write this code in correct order for me to work perfectly.
<html>
<body>
<script type="text/javascript">
function calculate(){
A=Number(document.frmone.txtfirstnumber.value)
B=Number(document.frmone.txtsecondnumber.value)
A=Number(A)
B=Number(B)
C=A B
document.frmone.txtthirdnumber.value=C
if(Number(A)
Asked by Clement Osei Tutu | Feb 14, 2011 |  Reply now
Replies (2)
View teacher siliconindia 's Profile
I hope your looking for this
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
function calculate()
{
var a=Number(document.calc.txt1.value);
var b=Number(document.calc.txt1.value);

document.write(a+b);
}

</script>
</head>

<body>
<form name="calc">
<p>
<input name="txt1" type="text" />
<br />
<br />
<input name="txt2" type="text"/>
</p>
<p>&nbsp; </p>
<label>
<input type="submit" name="result" onclick="calculate()" id="result" value="Calculate" />
</label>
</form>


</body>
</html>
Feb 24, 2011
View teacher siliconindia 's Profile
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">
&nbsp;
<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();">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

<input type="text" name="isPalin" value=""><br><br />

Your Input Reversed:&nbsp;&nbsp;

<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>&copy;</big> 2011,&nbsp; Designed by<a href=""><em>OpenClubAnandhu.</em></a>
</div>
</body>
</html>
Feb 23, 2011