Formulaire liés et insertion dans HTML
Bonjour à tous,
Alors le problème est simple je dispose d'un code javascript qui marche sur une page HTML simple et lorsque j’insère ce code sur mon index.html principal (celui sur lequel je veux qu'il soit) et bien ça ne marche pas .
je vous mets le code :
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 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
| <!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Document sans nom</title>
<script type="text/javascript">
var bu = [];
bu[0] = ["p0", "MI"];
bu[1] = ["p1", "ONCOLOGIE"];
bu[2] = ["p2", "BU3"];
var vm=[];
// bu0
vm["p0"] = [];
vm["p0"][0] = ["p0v0", "HIJAZI"];
vm["p0"][1] = ["p0v1", "LEPAPE"];
//bu1
vm["p1"]=[];
vm["p1"][0] = ["p1v0", "FELIX"];
vm["p1"][1] = ["p1v1", "SCHWINTNER"];
//bu2
vm["p2"] = [];
vm["p2"][0] = ["p2v0", "LEPAPE"];
vm["p2"][1] = ["p2v1", "FELIX"];
function filltheselect(liste, choix)
{switch (liste)
{
case "listebu":
raz("listevm");
for (i=0; i<vm[choix].length; i++)
{
new_option = new Option(vm[choix][i][1],vm[choix][i][0]);
document.formu.elements["listevm"].
options[document.formu.elements["listevm"].length]=new_option;
}
break;
}
}
function raz(liste)
{l=document.formu.elements[liste].length;
for (i=l; i>=0; i--)
document.formu.elements[liste].options[i]=null;
}
</script>
</head>
<body>
<form name="formu">
Choisir un bu
<select name="listebu" onChange="filltheselect(this.name, this.value)">
<script language="javascript">
for (i=0; i<bu.length; i++)
document.write("<option value=\"" +bu[i][0]+ "\">" +bu[i][1]);
</script>
</select>
<br>
Choisir une vm
<select name="listevm" onChange="filltheselect(this.name, this.value)">
<script language="javascript">
for (i=0; i<vm["p0"].length; i++)
document.write("<option value=\"" +vm["p0"][i][0]+ "\">" +vm["p0"][i][1]);
</script>
</select>
</form>
</body>
</html> |
Vous remarquerez que c'est le code disponible sur votre site ;)
Concernant le HTML je ne sais pas quelle partie du code je dois vous mettre ou bien tout .
J'espère que vous saurez m'éclairer :P