<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>
這是我的代碼。我需要我的瀏覽器從用戶提供的輸入中檢索值,並在表格的第二列中顯示計算結果。 代碼有問題嗎?調用函數裏面的一個函數的代碼
非常感謝。這解決了問題。 –
太棒了!很高興幫助:) – Sachin