-
Notifications
You must be signed in to change notification settings - Fork 0
/
shr.html
60 lines (49 loc) · 1.66 KB
/
shr.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
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Radio Buttons Example</title>
<script>
function abc()
{
var ele = document.getElementsByName("operation");
var opt;
for (i = 0; i < ele.length; i++)
{
if (ele[i].checked)
opt=ele[i].value;
}
var a=document.getElementById("N1").value;
var b=document.getElementById("N2").value;
if(opt=='+')
var c=parseInt(a)+parseInt(b);
else if(opt=='-')
var c=parseInt(a)-parseInt(b);
else if(opt=='/')
var c=parseInt(a)/parseInt(b);
else if(opt=='*')
var c=parseInt(a)*parseInt(b);
document.getElementById("N3").value=c;
}
</script>
</head>
<body>
Enter No : <input type="text" id="N1"> </input>
<br>
Enter No : <input type="text" id="N2"></input>
<br>
<br>
<h2>Select your operation:</h2>
<input type="radio" id="+" name="operation" value="+">
<label>SUM</label><br>
<input type="radio" id="-" name="operation" value="-">
<label >DIFF</label><br>
<input type="radio" id="/" name="operation" value="/">
<label >DIVI</label><br>
<input type="radio" id="*" name="operation" value="*">
<label >MULTI</label>
<br>
<button onclick="abc()">calculation</button>
<br>
<br>
Result : <input type="text" id="N3"></input>
</body>