The attached screenshot is my output. What I am trying to achieve is when I click AddWood, there will be 3 textbox generated (which is fine). the 3 textbox represent name, length and width. Once I hit calculate there should be a display below showing my the area, which is not working.
Can anyone help to point out where my mistake is?
function addText() {
var div1 = document.getElementById("div2");
div1.innerHTML = "<input type='text' id=Wname/><br> <input type='text' id=length/><br> <input type='text' id=width/>";
}
function myFunction() {
var length = document.getElementById("length").value;
var width = document.getElementById("width").value;
var area = length * width;
document.getElementById("Result").innerHTML = area;
}
<div id="div2"></div>
<input type="button" id="btnok" onclick="addText();" value="Add Wood"/>
<br />
<p><button onclick="myFunction()">Calculate</button>
<p id="Result"></p>
