Hoi,
Mijn vraag gaat over deze pagina : linkie
Ik wil zeg maar, dat als je bij ruimtes 10 selecteert, dat er 10x de drie inputs onder Afm. m² m plint komen. Hoe kan ik dit doen mbv javascript?
274 views
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Jan Koehoorn | Dynamic Inputs</title>
<script type="text/javascript" src="mootools/core.js"></script>
<script type="text/javascript">
window.addEvent ('domready', function () {
$('aantal').addEvent ('change', function () {
var divs = this.get ('value');
$('inputs').empty ();
for (i = 0; i < divs; i++) {
var input1 = new Element ('input', {'type':'text', 'name': 'value[]'});
var input2 = new Element ('input', {'type':'text', 'name': 'value[]'});
var input3 = new Element ('input', {'type':'text', 'name': 'value[]'});
var p = new Element ('p');
input1.inject (p);
input2.inject (p);
input3.inject (p);
p.inject ($('inputs'));
}
});
});
</script>
</head>
<body>
<form method="post" action="phphulp.php">
<div>
<select id="aantal" name="aantal">
<?php
foreach (range (1, 10) as $value) {
echo '
<option value="' . $value . '">' . $value . '</option>
';
}
?>
</select>
</div>
<div id="inputs">
</div>
</form>
</body>
</html>