-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvertor.html
More file actions
105 lines (99 loc) · 2.78 KB
/
convertor.html
File metadata and controls
105 lines (99 loc) · 2.78 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
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<!DOCTYPE html>
<html>
<head>
<title>Convertor</title>
<style>
* {
box-sizing: border-box;
padding: 0;
margin: 0;
}
#container {
width: 50%;
height: 40%;
border: 2px solid grey;
border-radius: 10px;
margin-left: 30%;
margin-top: 10%;
padding: 5px;
color: blue;
background-color: lightgrey;
box-shadow: 10px 10px 5px black;
}
#header {
width: inherit;
height: 20%;
text-align: center;
font-family: cursive;
font-size: 150%;
}
.textEle {
padding: 5px;
margin: 5px;
margin-left: 80px;
width: inherit;
border-radius: 2px;
}
</style>
</head>
<body>
<div id="container">
<div id="header">Decimal/Binary/Hexadecimal/Octal</div>
<hr />
Binary <br />
<input
type="text"
id="input1"
class="textEle"
onkeyup="fromBinary(this.value)"
autofocus
/>
<br />Decimal <br />
<input
type="text"
id="input2"
class="textEle"
onkeyup="fromDecimal(this.value)"
/>
<br />Octal <br />
<input
type="text"
id="input3"
class="textEle"
onkeyup="fromOctal(this.value)"
/>
<br />Hexadecimal <br />
<input
type="text"
id="input4"
class="textEle"
onkeyup="fromHexa(this.value)"
/>
</div>
<script>
function fromBinary(num) {
var num = '0b' + num;
document.getElementById('input2').value = Number(num).toString(10);
document.getElementById('input3').value = Number(num).toString(8);
document.getElementById('input4').value = Number(num).toString(16);
}
function fromDecimal(num) {
document.getElementById('input1').value = Number(num).toString(2);
document.getElementById('input3').value = Number(num).toString(8);
document.getElementById('input4').value = Number(num).toString(16);
}
function fromOctal(num) {
var num = '0o' + num;
document.getElementById('input1').value = Number(num).toString(2);
document.getElementById('input2').value = Number(num).toString(10);
document.getElementById('input4').value = Number(num).toString(16);
}
function fromHexa(num) {
var num = '0x' + num;
document.getElementById('input1').value = Number(num).toString(2);
document.getElementById('input2').value = Number(num).toString(10);
document.getElementById('input3').value = Number(num).toString(8);
}
</script>
</body>
</html>