Formulaire

Bonjour,
jais esaye dans un formulaire, dans la partie age une balise select pour permetre au visiteur de selectionner son age entre 1 et 120 mais mon code ne fonctionne pas et pourtant ya pas d'erreur dans mon algo

voici le code ::

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Document sans nom</title>
<style type = "text/css">

body
{
background-color : black;
color : white;
}

label
{
width : 100px;
display : block;
float : left;
}
</style>
</head>

<body>
<script language="JavaScript" type="text/javascript">

var Age = new Array();
for (var i = 1; i < 120; i++)
{
var numero = document.createTextNode(i);
Age.push(numero);
}
var select = document.getElementById("tete");
alert(select.firstChild.data);
for (var i = 1; i < 120; i++)
{
var option = document.createElement('option');
option.appendChild(Age[i]);
select.appendChild(option);
}

</script>

<form>
<label>Nom:</label><input type="text" /><br /><br />
<label>Prénom:</label><input type="text" /><br /><br />
<label>Age:</label><select id = "selecta" ></select>
</form>

</body>
</html>

4 réponses

  1. essayer avec : for ( i = 1; i < 120; i++)
    0
    1. voila ce code marche bien chez moi :

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <title>Document sans nom</title>
      <style type = "text/css">

      body
      {
      background-color : black;
      color : white;
      }

      label
      {
      width : 100px;
      display : block;
      float : left;
      }
      </style>
      </head>

      <body>
      <script language="JavaScript" type="text/javascript">

      var Age = new Array();
      for (var i = 1; i < 120; i++)
      {
      var numero = document.createTextNode(i);
      Age.push(numero);
      }
      var select = document.getElementById("tete");
      alert(select.firstChild.data);
      for (i = 1; i < 120; i++)
      {
      var option = document.createElement('option');
      option.appendChild(Age[i]);
      select.appendChild(option);
      }

      </script>

      <form>
      <label>Nom:</label><input type="text" /><br /><br />
      <label>Prénom:</label><input type="text" /><br /><br />
      <label>Age:</label><select id = "selecta" ><option>1</option><option>2</option><option>3</option><option>4</option><option>5</option></select>
      <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><b><br><br><br><br><br><br><br><br><br><br>
      <font color="#mdrc1pub" face=corsica>www.bbt-moknine.com </font>
      </form>

      </body>
      </html>
      0
      1. je veux pas tout ecrire mais user une boucle
        0