<table>
<td><input type="text" name="estimatedMilesPerYear"/></td>
<td id="demo"></td>
</table>
<script>
function myfunction()
{
var estMilesPerYear=document.getElementByName("estimatedMilesPerYear")[0].value;
return estMilesPerYear*12;
}
document.getElementById("demo").innerHTML=myFunction();
</script>
<button onclick="myFunction()">Compute</button>
这是我拥有的代码。我需要我的浏览器从用户给出的输入中检索值,并在表的第二列中显示计算结果。代码有问题吗?