I don't have hard drives. i just keep 30 chinese teenagers in my basement and force them to memorize numbers.
1
2
| var a = [ 1234, 12, 342456, 345634, 345, 87645, 76, 345 ]; alert (a.sort().pop()); |
[ Voor 15% gewijzigd door drm op 09-03-2004 19:36 ]
Music is the pleasure the human mind experiences from counting without being aware that it is counting
~ Gottfried Leibniz
I don't have hard drives. i just keep 30 chinese teenagers in my basement and force them to memorize numbers.
Maar zo zou ie het wel moeten doen:MSDN
default sort: the elements are sorted in ascending, ASCII character order
1
2
3
4
5
6
7
8
| var a = [ 1234, 12, 342456, 345634, 345, 87645, 76, 345 ];
alert (a.sort(mysort).pop());
function mysort(a, b) {
if(a < b) return -1;
if(a == b) return 0;
if(a > b) return 1;
} |
[ Voor 15% gewijzigd door Amras op 09-03-2004 19:52 ]
Euh, ja, je hebt gelijk. Ik was iets te snelDries_Aendekerk:
Ik krijg een alert met "87645" als waarde. Moet dit niet "345634" zijn, of bedoelde je de hoogste waarde niet?
Overigens kun je voor dergelijke zaken het beste even de javascript reference erop naslaan in plaats van MSDN. Bij MSDN weet je namelijk nooit zeker of het niet toevallig een IE implementatie is of dat het inderdaad ook in andere browsers werkt.
Music is the pleasure the human mind experiences from counting without being aware that it is counting
~ Gottfried Leibniz
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| Array.prototype.max = function() { var m = null, i = this.length; if (i) m = this[--i]; while (i--) { if (this[i] > m) m = this[i]; } return m; } var a = [ 1234, 12, 342456, 345634, 345, 87645, 76, 345 ]; alert(a.max()); |
Intentionally left blank
Kan iemand me helpen?
Het zit zo:
(zie ook http://www.aendekerk.be/formulier.html)
Vier tekstvakjes ("b1x1_totaal", "b1x2_totaal", "b1x3_totaal", "b1x4_totaal") hebben een bepaalde (totaal)waarde (ingegeven door de gebruiker). Nu zou ik willen dat (onkeyup of zo) al die waardes op nul worden gezet, behalve de hoogste waarde.
Hoe speel ik dit klaar?
[ Voor 6% gewijzigd door DriesA op 10-03-2004 08:35 ]
I don't have hard drives. i just keep 30 chinese teenagers in my basement and force them to memorize numbers.
Verwijderd
1
2
3
| with(Math) { var theMax = max( max(a, b), max(c, d) ); } |
Music is the pleasure the human mind experiences from counting without being aware that it is counting
~ Gottfried Leibniz
1
2
3
4
5
6
7
8
9
10
11
| function grootste(b1x1_totaal, b1x2_totaal, b1x3_totaal ) {
if(b1x1_totaal < b1x2_totaal) var b1x1_totaal = 0;
if(b1x1_totaal < b1x3_totaal) var b1x1_totaal = 0;
if(b1x2_totaal < b1x1_totaal) var b1x2_totaal = 0;
if(b1x2_totaal < b1x3_totaal) var b1x2_totaal = 0;
if(b1x3_totaal < b1x1_totaal) var b1x3_totaal = 0;
if(b1x3_totaal < b1x2_totaal) var b1x3_totaal = 0;
return b1x1_totaal;
return b1x2_totaal;
return b1x3_totaal;
} |
I don't have hard drives. i just keep 30 chinese teenagers in my basement and force them to memorize numbers.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| var highestValue = b1x1_totaal.value;
var highestNode = b1x1_totaal;
for(var i = 2; i <= 4; i++) {
if(window['b1x'+i+'_totaal'].value > highestValue) {
highestValue = window['b1x'+i+'_totaal'].value;
highestNode = window['b1x'+i+'_totaal'];
}
}
for(var i = 1; i <= 4; i++) {
if(window['b1x'+i+'_totaal'] == highestNode) {
continue;
}
else {
window['b1x'+i+'_totaal'].value = "";
}
} |
I don't have hard drives. i just keep 30 chinese teenagers in my basement and force them to memorize numbers.
Het probleem is ondertussen opgelost.
Toch bedankt!
(voor de geïnteresseerden: http://www.aendekerk.be/beta/airco/bereken.html)
I don't have hard drives. i just keep 30 chinese teenagers in my basement and force them to memorize numbers.
Music is the pleasure the human mind experiences from counting without being aware that it is counting
~ Gottfried Leibniz