Ajouter un input (appendchild) ne fonctionne pas
bonjour a tous
pour un projet en vba je me tourne un peu vers le html et javascript
j'essai de trouver comment ajouter un input a chaque fois que je tape dans un imput
j'explique dans le formulaire il y a 1 input je tape montexte et en tapant entré cela devrait m'ajouter un nouveau imput et ainsi de suite
mais visiblement il y a quelque chose que je n'ai pas capter
Code:
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
| <html>
<head>
<title></title>
<script type="text/javascript">
function ajoute(e){
if (e.keyCode == 13)
{
alert("Hello! I am an alert box!!");
var myinput = document.createElement("input");
}
myinput.type = "text";
myinput.id="ligne2";
document.getElementById("divparent").appendChild(myinput);
//-->
</script>
</head>
<body>
<form action="" method="post">
<div id="divParent">
<input type="text" id ="ligne1" onkeypress="ajoute(event)"/>
<br />
<br />
</div>
</Form>
</body>
</html> |
qurlqu'un pourrait me dire pourquoi?
je tourne avec windows 7 et Ie 10