-
Notifications
You must be signed in to change notification settings - Fork 0
/
HTML3_03082190017.html
77 lines (63 loc) · 2.08 KB
/
HTML3_03082190017.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<!DOCTYPE html>
<head>
<title>
Using Promp for Interaction with User
</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<p>
Click button for start prompt
</p>
<button type="button" name="btnShow" onclick="callPrompt()">
Click Me!
</button>
<p id="demoPrompt"></p>
<script>
function callPrompt()
{
var namaUser = prompt("Please enter your name : ");
if(namaUser != null || namaUser != " ")
{
document.getElementById("demoPrompt").innerHTML = "Hello " + namaUser;
}
}
</script>
<br>
<br>
<input name="inputLoop" size="40">
<button type="button" name="prosesLoop" onclick="fillLoop()">
Click Me!
</button>
<br>
<br>
<p>Masukkan indeks array untuk menampilkan nama</p>
<input name="inputIndeks" size="40">
<button type="button" name="cariNama" onclick="getNamaByIndeks()">
Click Me!
</button>
<script>
var nama = new Array();
function fillLoop()
{
if(!document.getElementById) return;
nilaiBatas = document.getElementsByName("inputLoop")[0].value;
for(i=0; i<nilaiBatas; i++)
{
alert("Nilai: "+i);
nama[i] = prompt("Please enter your name : ");
}
/*for(i=0; i<nilaiBatas; i++)
{
document.write("<br>");
document.write(nama[i]);
}*/
}
function getNamaByIndeks()
{
nilaiNama = document.getElementsByName("inputIndeks")[0].value;
alert(nama[nilaiNama]);
}
</script>
</body>
</html>