textbox-counter
Code (php)
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
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
<script type="text/javascript">
var mouseDown = false;
var countType;
var counter = 0;
var nextTime;
function count()
{
if (mouseDown)
{
if (isNaN(document.getElementById('aantal').value))
{
document.getElementById('aantal').value = 0;
}
counter++;
if (countType)
{
document.getElementById('aantal').value ++;
}
else
{
document.getElementById('aantal').value --;
}
nextTime = 200 / counter;
if (nextTime < 10)
{
nextTime = 10;
}
setTimeout('count();', nextTime);
}
}
function startCount(type)
{
mouseDown = true;
countType = type;
counter = 0;
count();
}
function stopCount()
{
mouseDown = false;
}
</script>
<style type="text/css">
#counter-container
{
position: relative;
width: 200px;
border: 1px solid #ccc;
}
#up
{
position: absolute;
top: 0px;
right: 0px;
}
#down
{
position: absolute;
bottom: 0px;
right: 0px;
}
#aantal
{
font: 11px verdana;
border: 0;
}
</style>
<noscript>Voor deze functie is JavaScript nodig.</noscript>
<div id="counter-container">
<input id="aantal" type="text" value="0" />
<img id="up" src="up.gif" onmousedown="startCount(true);" onmouseup="stopCount();" onmouseout="stopCount();" />
<img id="down" src="down.gif" onmousedown="startCount(false);" onmouseup="stopCount();" onmouseout="stopCount();" />
</div>
var mouseDown = false;
var countType;
var counter = 0;
var nextTime;
function count()
{
if (mouseDown)
{
if (isNaN(document.getElementById('aantal').value))
{
document.getElementById('aantal').value = 0;
}
counter++;
if (countType)
{
document.getElementById('aantal').value ++;
}
else
{
document.getElementById('aantal').value --;
}
nextTime = 200 / counter;
if (nextTime < 10)
{
nextTime = 10;
}
setTimeout('count();', nextTime);
}
}
function startCount(type)
{
mouseDown = true;
countType = type;
counter = 0;
count();
}
function stopCount()
{
mouseDown = false;
}
</script>
<style type="text/css">
#counter-container
{
position: relative;
width: 200px;
border: 1px solid #ccc;
}
#up
{
position: absolute;
top: 0px;
right: 0px;
}
#down
{
position: absolute;
bottom: 0px;
right: 0px;
}
#aantal
{
font: 11px verdana;
border: 0;
}
</style>
<noscript>Voor deze functie is JavaScript nodig.</noscript>
<div id="counter-container">
<input id="aantal" type="text" value="0" />
<img id="up" src="up.gif" onmousedown="startCount(true);" onmouseup="stopCount();" onmouseout="stopCount();" />
<img id="down" src="down.gif" onmousedown="startCount(false);" onmouseup="stopCount();" onmouseout="stopCount();" />
</div>