Direct optellen bij aanpassen tekst veld
Mike Z
08/06/2012 11:18:14Ja hoe doe ik dat dus? Ik heb nu dit maar het werkt niet:
<script type="text/javascript">
function tel()
{
var getal1 = (document.javascript.kids);
var getal2 = (document.javascript.auto);
var tot= getal1+getal2;
document.getElementById('resultaat').innerHTML =(tot);
}
</script>
<form action="" method="post">
kinderen: <input name="kids" type="text" onchange="tel()" />
auto: <input name="auto" type="text" onchange="tel()" />
<br />
<span id="resultaat"></span>
</form>
<script type="text/javascript">
function tel()
{
var getal1 = (document.javascript.kids);
var getal2 = (document.javascript.auto);
var tot= getal1+getal2;
document.getElementById('resultaat').innerHTML =(tot);
}
</script>
<form action="" method="post">
kinderen: <input name="kids" type="text" onchange="tel()" />
auto: <input name="auto" type="text" onchange="tel()" />
<br />
<span id="resultaat"></span>
</form>
PHP hulp
25/11/2024 08:59:19Kris Peeters
08/06/2012 11:34:53Dat kan bv. zo (m.a.w. er zijn nog talloze andere mogelijkheden)
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<!doctype HTML>
<html>
<head>
<script type="text/javascript">
function tel()
{
var getal1 = Number( document.getElementById('kids').value );
var getal2 = Number( document.getElementById('auto').value );
var tot = getal1 + getal2;
document.getElementById('resultaat').innerHTML = tot;
}
</script>
</head>
<body>
<form action="" method="post">
kinderen: <input id="kids" name="kids" type="text" onchange="tel()" />
auto: <input id="auto" name="auto" type="text" onchange="tel()" />
<br />
<span id="resultaat"></span>
</form>
</body>
</html>
<html>
<head>
<script type="text/javascript">
function tel()
{
var getal1 = Number( document.getElementById('kids').value );
var getal2 = Number( document.getElementById('auto').value );
var tot = getal1 + getal2;
document.getElementById('resultaat').innerHTML = tot;
}
</script>
</head>
<body>
<form action="" method="post">
kinderen: <input id="kids" name="kids" type="text" onchange="tel()" />
auto: <input id="auto" name="auto" type="text" onchange="tel()" />
<br />
<span id="resultaat"></span>
</form>
</body>
</html>