- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswitch_case.html
More file actions
Latest commit
113 lines (89 loc) · 3.65 KB
/
Copy pathswitch_case.html
File metadata and controls
113 lines (89 loc) · 3.65 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
106
107
108
109
110
111
112
113
<!DOCTYPE html>
<htmllang="en">
<head>
<metacharset="UTF-8">
<title>demo</title>
<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body>
<h3onclick="getData(1)">1</h3>
<h3onclick="getData(2)">2</h3>
<h3onclick="getData(3)">3</h3>
<h3onclick="getData(4)">4</h3>
<h3onclick="getData(5)">5</h3>
<h3onclick="getData(6)">6</h3>
<buttononclick="getData()">Click</button>
<pid="nu"></p>
<script>
functiongetData(value){
switch(value){
case1 : document.getElementById('nu').innerHTML=document.getElementById('nu').innerHTML+'<br/>'+'Floor No. 1';
break;
case2 : document.getElementById('nu').innerHTML=document.getElementById('nu').innerHTML+'<br/>'+'Floor No. 2';
break;
case3 : document.getElementById('nu').innerHTML=document.getElementById('nu').innerHTML+'<br/>'+'Floor No. 3';
break;
case4 : document.getElementById('nu').innerHTML=document.getElementById('nu').innerHTML+'<br/>'+'Floor No. 4';
break;
case5 : document.getElementById('nu').innerHTML=document.getElementById('nu').innerHTML+'<br/>'+'Floor No. 5';
break;
case6 : document.getElementById('nu').innerHTML=document.getElementById('nu').innerHTML+'<br/>'+'Floor No. 6';
break;
default : document.getElementById('nu').innerHTML=document.getElementById('nu').innerHTML+'<br/>'+'Ground Floor';
}
}
</script>
<form>
<inputtype="text" name="" value="" id="day" />
<inputtype="submit" name="" value="Submit" onclick="getData2()" />
</form>
<br/>
<script>
functiongetData2(){
vardayV=document.getElementById('day').value;
dayV=dayV.toLowerCase();
switch(dayV){
case'sunday' :
case'saturday' : document.write('Today is Weekend');
break;
case'wednesday' :
case'friday' :
case'thursday' :
case'tuesday' :
case'monday' :
document.write('Today is Weekdays');
break;
default : document.write('please enter correct day');
}
}
</script>
<br/><br/>
<inputtype="text" name="" value="" id="val1" />
<inputtype="text" name="" value="" id="val2" />
<selectid="opr">
<optionvalue="Add">Add</option>
<optionvalue="Subtract">Subtract</option>
<optionvalue="Multiply">Multiply</option>
<optionvalue="Divide">Divide</option>
</select>
<inputtype="submit" name="" value="Submit" onclick="operation()" />
<pid="ope"></p>
<script>
functionoperation(){
varv1=parseInt(document.getElementById('val1').value);
varv2=parseInt(document.getElementById('val2').value);
varo2=document.getElementById('opr').value;
switch(o2){
case'Add' : alert(v1+v2);
break;
case'Subtract' : document.write(v1-v2);
break;
case'Multiply' : console.log(v1*v2);
break;
case'Divide' : alert(v1/v2);
break;
}
}
</script>
</body>
</html>