Tuesday, November 4, 2008

Javascript Image

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>

No comments:

Post a Comment