-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathif_else.html
More file actions
244 lines (223 loc) · 9.73 KB
/
if_else.html
File metadata and controls
244 lines (223 loc) · 9.73 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>demo</title>
</head>
<body>
<p><b>Get Data on click on it</b></p>
<a onclick="getData(1)">1</a> | <a onclick="getData(2)">2</a> | <a onclick="getData(3)">3</a>
| <a onclick="getData(4)">4</a> | <a onclick="getData(5)">5</a> | <a onclick="getData(6)">6</a>
<br/>
<p id="nu"></p>
<script>
function getData(value){
if(value == 1){
document.getElementById('nu').innerHTML = document.getElementById('nu').innerHTML + '<br/>' +'Floor no. 1';
}else if(value == 2){
document.getElementById('nu').innerHTML = document.getElementById('nu').innerHTML + '<br/>' +'Floor no. 2';
}else if(value == 3){
document.getElementById('nu').innerHTML = document.getElementById('nu').innerHTML + '<br/>' +'Flooe no. 3';
}else if(value == 4){
document.getElementById('nu').innerHTML = document.getElementById('nu').innerHTML + '<br/>' +'Floor no. 4';
}else if(value == 5){
document.getElementById('nu').innerHTML = document.getElementById('nu').innerHTML + '<br/>' +'Flooe no. 5';
}else if(value == 6){
document.getElementById('nu').innerHTML = document.getElementById('nu').innerHTML + '<br/>' +'Floor no. 6';
}else{
document.getElementById('nu').innerHTML = document.getElementById('nu').innerHTML + '<br/>' +'Ground Floor';
}
}
</script>
<p><b>Check whether number is Even / Odd / Fractional</b></p>
<input type="text" name="" value="" id="numb" />
<input type="submit" name="" value="Even / Odd / Fractional" onclick="getData2()" />
<script>
function getData2(){
var numV = document.getElementById('numb').value;
if(numV%2 == 0){
alert('Even');
}else if(numV%2 == 1){
alert('Odd');
}
else {
alert('Fractional');
}
}
</script>
<p><b>Check Remainder Value?</b></p>
<input type="text" name="" value="" id="numb1" />
<input type="text" name="" value="" id="numb2" />
<input type="submit" name="" value="Remainder" onclick="getData3()" />
<script>
function getData3(){
var a = parseInt(document.getElementById('numb1').value);
var b = parseInt(document.getElementById('numb2').value);
var r = a % b;
alert('Remainder Result :' + r);
}
</script>
<p><b>Number is Prime or not?</b></p>
<input type="text" name="" value="" id="numb3" />
<input type="submit" name="" value="Is Prime" onclick="isPrime()" />
<script>
function isPrime(){
var pV = document.getElementById('numb3').value;
var pV1 = '0';
for(i = 2; i < pV; i++){
if(pV % i == 0){
pV1++;
}
}
if(pV1 == 0){
alert('Prime Number');
}else{
alert('Not Prime Number');
}
}
</script>
<p><b>Arrange the number Ascending/ Descending?</b></p>
<input type="text" name="" value="" id="n1" onblur="if(this.value == '' || isNaN(this.value)){this.value = 0} " />
<input type="text" name="" value="" id="n2" />
<input type="text" name="" value="" id="n3" />
<input type="text" name="" value="" id="n4" />
<input type="text" name="" value="" id="n5" />
<select onchange="drADC(value)">
<option value="">Select</option>
<option value="Ascending">Ascending</option>
<option value="Descending">Descending</option>
</select>
<!-- <select id="drAD">
<option>Ascending</option>
<option>Descending</option>
</select>
<input type="button" name="" value="SORT / REVERSE" onclick="SR()" />
<input type="button" name="" value="Ascending" onclick="asc()" />
<input type="button" name="" value="Descending" onclick="desc()" />-->
<p id="nvRe"></p>
<script>
function drADC(value){
var dataArr = [];
for(i = 1; i < 6; i++){
var dataV = document.getElementById('n' + i).value;
dataV = (dataV == '' || isNaN(dataV)) ? 0 : dataV;
//document.getElementById('n' + i).value = dataV;
dataArr.push(dataV);
}
var adV = value;
var nvRslt;
switch(adV){
case 'Ascending' : nvRslt = dataArr.sort(function(a, b){return a - b});
document.getElementById('nvRe').innerHTML = nvRslt;
break;
case 'Descending' : nvRslt = dataArr.sort(function(a,b) {return b - a});
document.getElementById('nvRe').innerHTML = nvRslt;
break;
}
}
/*function drADC(value){
var nV1 = parseInt(document.getElementById('n1').value);
var nV2 = parseInt(document.getElementById('n2').value);
var nV3 = parseInt(document.getElementById('n3').value);
var nV4 = parseInt(document.getElementById('n4').value);
var nV5 = parseInt(document.getElementById('n5').value);
var nVarr = [nV1, nV2, nV3, nV4, nV5];
var adV = value;
var nVRslt;
switch(adV){
case 'Ascending' : nVRslt = nVarr.sort(function(a,b){return a - b});
document.getElementById('nvRe').innerHTML = nVRslt;
break;
case 'Descending' : nVRslt = nVarr.sort(function(a,b){return b - a});
document.getElementById('nvRe').innerHTML = nVRslt;
break;
}
}*/
/*function SR(){
var nV1 = parseInt(document.getElementById('n1').value);
var nV2 = parseInt(document.getElementById('n2').value);
var nV3 = parseInt(document.getElementById('n3').value);
var nV4 = parseInt(document.getElementById('n4').value);
var nV5 = parseInt(document.getElementById('n5').value);
var nVarr = [nV1, nV2, nV3, nV4, nV5];
var adV = document.getElementById('drAD').value;
var nVRslt;
switch(adV){
case 'Ascending' : nVRslt = nVarr.sort(function(a,b){return a - b});
document.getElementById('nvRe').innerHTML = nVRslt;
break;
case 'Descending' : nVRslt = nVarr.sort(function(a,b){return b - a});
document.getElementById('nvRe').innerHTML = nVRslt;
break;
}
}*/
/*function asc(){
var nV1 = parseInt(document.getElementById('n1').value);
var nV2 = parseInt(document.getElementById('n2').value);
var nV3 = parseInt(document.getElementById('n3').value);
var nV4 = parseInt(document.getElementById('n4').value);
var nV5 = parseInt(document.getElementById('n5').value);
var nVarr = [nV1, nV2, nV3, nV4, nV5];
var nVRslt;
nVRslt = nVarr.sort(function(a,b){return a - b});
document.getElementById('nvRe').innerHTML = nVRslt;
}
function desc(){
var nV1 = parseInt(document.getElementById('n1').value);
var nV2 = parseInt(document.getElementById('n2').value);
var nV3 = parseInt(document.getElementById('n3').value);
var nV4 = parseInt(document.getElementById('n4').value);
var nV5 = parseInt(document.getElementById('n5').value);
var nVarr = [nV1, nV2, nV3, nV4, nV5];
var nVRslt;
nVRslt = nVarr.sort(function(a,b){return b - a});
document.getElementById('nvRe').innerHTML = nVRslt;
}*/
</script>
<p><b>Check the number Alphabetic or Numeric?</b></p>
<input type="text" name="" value="" id="NA" />
<input type="button" name="" value="Number / Alphabets" onclick="numAlpha()" />
<script>
function numAlpha(){
//var fV = document.getElementById('NA').value;
if(isNaN(document.getElementById('NA').value)){
alert('The Value is Alphabetic');
}else{
alert('The Value is Numeric');
}
}
</script>
<br/><br/>
<input type="text" name="" value="" id="exA" />
<input type="button" name="" value="@ exists" onclick="existA()" />
<p><b>@ exist in the text Filed?</b></p>
<script>
function existA(){
var ltrS = document.getElementById('exA').value;
var ltrRs = ltrS.indexOf('@');
if(ltrRs == -1){
alert('@ not exist in the text Filed');
}else{
alert('@ exist in the text Filed');
}
}
</script>
<br/><br/>
<p><b>write previous text of @</b></p>
<input type="email" name="" value="" id="eml" />
<input type="button" name="" value="before @ Split" onclick="emlSplt()" />
<p id="sEmL"></p>
<script>
function emlSplt(){
var emDt = document.getElementById('eml').value;
var emLs = emDt.indexOf('@');
if(emLs == -1){
document.getElementById('sEmL').innerHTML = '@ not exist in text field';
}else{
var emS = emDt.substr(0, emLs);
document.getElementById('sEmL').innerHTML = emS;
}
}
</script>
</body>
</html>