about summary refs log tree commit diff
path: root/usth/ICT3.2/prac/2/11.html
blob: 51c09222821965b706260d2118f46e6638b92bd5 (plain) (blame)
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
<!DOCTYPE html>
<style>
h1 { text-align: center }
form {
    display: table;
    margin: 0 auto;
}
p { display: table-row }
.cell {
    display: table-cell;
    margin: 0.2em 0;
}
</style>

<script>
function get() {
    return [document.getElementById('1st').value,
            document.getElementById('2nd').value];
}

function mul() {
    document.getElementById('result').innerHTML = (
        (x, y) => x * y)(...get());
}

function div() {
    document.getElementById('result').innerHTML = (
        (x, y) => x / y)(...get());
}
</script>

<html>
<body>
  <form>
    <p>
      <label class=cell for=1st>1st Number:&emsp;</label>
      <input class=cell type=text id=1st>
    </p>
    <p>
      <label class=cell for=2nd>2nd Number:&emsp;</label>
      <input class=cell type=text id=2nd>
    </p>
    <p>
      <span class=cell></span>
      <span class=cell>
        <input type=button onclick='mul()' value=Multiply>
        <input type=button onclick='div()' value=Divide>
      </span>
    <p>
      <span class=cell>The Result is:&emsp;</span>
      <span id=result></span>
    </p>
  </form>
</body>
</html>