HTMLJavaScript

JavaScript Program to Calculate the Total of Length, Width & Height

Write a JavaScript Program to Calculate the Total of Length, Width, and Height. Write javascript code to calculate the volume if the length, breadth and height are given by the user with the help of form.

<html>

<head>

<script>

  function calculatevolume(length, width, height) {

    volume =  width * height * length

    return volume

  }

</script>

</head>

<body>

<form name="volfrm">

Length<input type="text" name="txtlength"/><br />

Width<input type="text" name="txtwidth" /><br />

Height<input type="text" name="txtheight"/><br />

<input type="submit" value="calculate" onClick="alert(calculatevolume(document.volfrm.txtlength.value, document.volfrm.txtwidth.value, document.volfrm.txtheight.value))" />

</form>

</body>

</html>
Back to top button