function calculate() { var width=document.getElementById("wid").value; var length=document.getElementById("len").value; document.getElementById("diagonal").value=Math.round(Math.sqrt((length*length+width*width))*10000)/10000; document.getElementById("area").value=Math.round(length*width*10000)/10000; document.getElementById("perimeter").value=Math.round((2*length+2*width)*10000)/10000; }