practice14(구구단 업글).html
1.1 KB
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>구구단</title>
</head>
<body>
<div id="div1">
<h1>** 구구단 출력 **</h1>
</div>
<div id="div2">
단:<select class="" name="dan" onchange="selectEvent(this)">
<option value="2">2단</option>
<option value="3">3단</option>
<option value="4" selected>4단</option>
<option value="5">5단</option>
<option value="6">6단</option>
<option value="7">7단</option>
<option value="8">8단</option>
<option value="9">9단</option>
</select>
</div>
<div id="div3">
</div>
<script type="text/javascript">
function selectEvent(selectObj) {
var value = selectObj.value;
func(value);
}
function func(number) {
var total = "";
var temp= "";
for(var i = 1; i <= 9; i++){
temp+=( number + " * " + i + " = " + number*i + "<br>")
}
total +=temp;
document.getElementById("div3").innerHTML = total;
}
</script>
</body>
</html>