Create a web page containing a form allowing the user to enter variables for some type of calculation. Write a JavaScript program to perform the calculation. When the user clicks a button, your page displays the calculated results. For example, create a form that allows the user to enter variables to calculate the square footage of a rectangular room (area = length * width).
<html>
<head>
<script>
function f1()
{
dqm1=document.form1.length.value;
dqm1=parseInt(dqm1);
y=document.form1.width.value;
y=parseInt(y);
area=dqm1*y;
alert("Area is "+area);
}
</script>
</head>
<body>
<form name="form1">
Enter length <input type="text" name="length" />
</br>
Enter width<input type="text" name="width" />
<input type="submit" value="click me" onclick="f1()">
</form>
</body>
</html>
Get Answers For Free
Most questions answered within 1 hours.