Demo of math calculator in JavaScript

+
Here is the source code

<html>
<head>
<title>Demo Calculator by taking two inputs and adding</title>
</head>
<body>

<script language='JavaScript' type='text/JavaScript'>
<!--
var d1 = 0;
var d2 = 0;
function reset(){
output='';
data.length=0;
document.getElementById('t1').value=output;
document.getElementById('res').innerHTML=output;
document.getElementById('t1').focus()
}

function result(){
d1= parseFloat(document.getElementById('t1').value);
d2= parseFloat(document.getElementById('t2').value);

var res = d1 + d2 ;

document.getElementById('res').innerHTML=res;

}

//-->
</script>

<input type=text id=t1 style="TextAlign:Right;" size='6'> +
<input type=text id=t2 style="TextAlign:Right;" size='6'>

<input type=button value='=' size=5 onClick="result();">

<div id='res'></div>

</body>
</html>



plus2net.com




mksharmil

23-03-2014

nice job! if input boxes are arrays in multiple rows and id's are like ="txt[]" rather than "txt"
how should we calculate then?

Post your comments , suggestion , error , requirements etc here .




We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2020 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer