- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathif_else.html
More file actions
Latest commit
244 lines (223 loc) · 9.73 KB
/
Copy pathif_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>
<htmllang="en">
<head>
<metacharset="UTF-8">
<title>demo</title>
</head>
<body>
<p><b>Get Data on click on it</b></p>
<aonclick="getData(1)">1</a> | <aonclick="getData(2)">2</a> | <aonclick="getData(3)">3</a>
| <aonclick="getData(4)">4</a> | <aonclick="getData(5)">5</a> | <aonclick="getData(6)">6</a>
<br/>
<pid="nu"></p>
<script>
functiongetData(value){
if(value==1){
document.getElementById('nu').innerHTML=document.getElementById('nu').innerHTML+'<br/>'+'Floor no. 1';
}elseif(value==2){
document.getElementById('nu').innerHTML=document.getElementById('nu').innerHTML+'<br/>'+'Floor no. 2';
}elseif(value==3){
document.getElementById('nu').innerHTML=document.getElementById('nu').innerHTML+'<br/>'+'Flooe no. 3';
}elseif(value==4){
document.getElementById('nu').innerHTML=document.getElementById('nu').innerHTML+'<br/>'+'Floor no. 4';
}elseif(value==5){
document.getElementById('nu').innerHTML=document.getElementById('nu').innerHTML+'<br/>'+'Flooe no. 5';
}elseif(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>
<inputtype="text" name="" value="" id="numb" />
<inputtype="submit" name="" value="Even / Odd / Fractional" onclick="getData2()" />
<script>
functiongetData2(){
varnumV=document.getElementById('numb').value;
if(numV%2==0){
alert('Even');
}elseif(numV%2==1){
alert('Odd');
}
else{
alert('Fractional');
}
}
</script>
<p><b>Check Remainder Value?</b></p>
<inputtype="text" name="" value="" id="numb1" />
<inputtype="text" name="" value="" id="numb2" />
<inputtype="submit" name="" value="Remainder" onclick="getData3()" />
<script>
functiongetData3(){
vara=parseInt(document.getElementById('numb1').value);
varb=parseInt(document.getElementById('numb2').value);
varr=a%b;
alert('Remainder Result :'+r);
}
</script>
<p><b>Number is Prime or not?</b></p>
<inputtype="text" name="" value="" id="numb3" />
<inputtype="submit" name="" value="Is Prime" onclick="isPrime()" />
<script>
functionisPrime(){
varpV=document.getElementById('numb3').value;
varpV1='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>
<inputtype="text" name="" value="" id="n1" onblur="if(this.value == '' || isNaN(this.value)){this.value = 0} " />
<inputtype="text" name="" value="" id="n2" />
<inputtype="text" name="" value="" id="n3" />
<inputtype="text" name="" value="" id="n4" />
<inputtype="text" name="" value="" id="n5" />
<selectonchange="drADC(value)">
<optionvalue="">Select</option>
<optionvalue="Ascending">Ascending</option>
<optionvalue="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()" />-->
<pid="nvRe"></p>
<script>
functiondrADC(value){
vardataArr=[];
for(i=1;i<6;i++){
vardataV=document.getElementById('n'+i).value;
dataV=(dataV==''||isNaN(dataV)) ? 0 : dataV;
//document.getElementById('n' + i).value = dataV;
dataArr.push(dataV);
}
varadV=value;
varnvRslt;
switch(adV){
case'Ascending' : nvRslt=dataArr.sort(function(a,b){returna-b});
document.getElementById('nvRe').innerHTML=nvRslt;
break;
case'Descending' : nvRslt=dataArr.sort(function(a,b){returnb-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>
<inputtype="text" name="" value="" id="NA" />
<inputtype="button" name="" value="Number / Alphabets" onclick="numAlpha()" />
<script>
functionnumAlpha(){
//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/>
<inputtype="text" name="" value="" id="exA" />
<inputtype="button" name="" value="@ exists" onclick="existA()" />
<p><b>@ exist in the text Filed?</b></p>
<script>
functionexistA(){
varltrS=document.getElementById('exA').value;
varltrRs=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>
<inputtype="email" name="" value="" id="eml" />
<inputtype="button" name="" value="before @ Split" onclick="emlSplt()" />
<pid="sEmL"></p>
<script>
functionemlSplt(){
varemDt=document.getElementById('eml').value;
varemLs=emDt.indexOf('@');
if(emLs==-1){
document.getElementById('sEmL').innerHTML='@ not exist in text field';
}else{
varemS=emDt.substr(0,emLs);
document.getElementById('sEmL').innerHTML=emS;
}
}
</script>
</body>
</html>