Programming

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

Total of Length

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>

Tuts

About Author

Tutsmaster.org provides tutorials related to tech and programmings. We are also setting up a community for the users and students.