Following JS shows how to use images. An image can be picked from a website or from local drive.
Size of image can be given either by width or height or both. It can be left or right aligned.
To get image from local drive, source can be specified as src="file:///C:/Ruchi/calcu.jpg"
< html>
< img width="100pix" align="left" border="0" alt="calculator"
src="http://www.understandingmoney.gov.au/image/calculator.GIF">
Calculate
< body>
< input type = "textarea" onchange="javascript:func(this.value)" / >
< input type = "button" value="Go"/>
< div id= "mydiv"> < /div>
< /body>
< script type ="text/javascript">
function func(a)
{
var ansr = eval(a);
var e = document.getElementById("mydiv");
e.innerHTML = "Answer : " + ansr;
}
< /script>
< /html>
Tuesday, November 4, 2008
Sunday, November 2, 2008
JavaScript Calculator
This script creates a simple calculator in browser.
<html>
Calculate
<body>
<input type="textarea" onchange="javascript:funky(this.value);" />
<div id="mydata"></div>
</body>
<script>
function funky(a)
{
var ansr = eval(a);
var e = document.getElementById("mydata");
e.innerHTML = "Result of expression : " + a + " is :" + ansr ;
}
</script>
</html>
<html>
Calculate
<body>
<input type="textarea" onchange="javascript:funky(this.value);" />
<div id="mydata"></div>
</body>
<script>
function funky(a)
{
var ansr = eval(a);
var e = document.getElementById("mydata");
e.innerHTML = "Result of expression : " + a + " is :" + ansr ;
}
</script>
</html>
Subscribe to:
Posts (Atom)