<html>
<head>
<title> Belajar array</title>
<script type=text/javascript>
var angka=["8","9","10"];
var hitung=[];
function kuadrat()
{
for (m=0; m<=2; m++)
{
var x=angka[m]*angka[m];
hitung[m]=x;
}
document.getElementById("hasil_1").value=hitung[0];
document.getElementById("hasil_2").value=hitung[1];
document.getElementById("hasil_3").value=hitung[2];
}
</script>
</head>
<body bgcolor=brown>
angka awal <br>
<input type=text value=8 size=2>
<input type=text value=9 size=2>
<input type=text value=10 size=2><br>
<input type=button value=kuadratkan onclick='kuadrat();'><br>
hasil <br>
<input type=text id=hasil_1 size=10>
<input type=text id=hasil_2 size=10>
<input type=text id=hasil_3 size=10>
</body>
</html>
Tidak ada komentar:
Posting Komentar