par
seayoung » 13 oct. 2005, 14:29
je vais vous donner les tableau en plus et normalement avec ca vous aurez tout ...
enfin voilà en gros le process:
Sur la page formulaire :
Code : Tout sélectionner
<!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" lang="fr" xml:lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" media="screen, projection" href="formulaire.css" />
<script src="control.js" type="text/javascript"></script>
<title>formulaire</title>
</head>
<body>
<form action="<?php echo $action; ?>" method="post">
<select name="nom1" onchange="reloadList(document.forms[0].nom1,document.forms[0].nom2, tableau_titre_valeur_select2, true, false);">
<option value=""> </option>
<option value="valA" >TitreA</option>
<option value="valB" >TitreB</option>
</select>
MON second select
<select name="nom2">
<option value=""> </option>
<option value="val1" >titreA 1</option>
<option value="val2" >titreA 2</option>
</select>
<input type="submit" id="btprecedent" name="valid" value="valider" />
</body>
</html>
et dans le fichier control.js:
Code : Tout sélectionner
tableau_titre_valeur_select2[2]=new Array(5);
tableau_titre_valeur_select2[2][0]="valA";
tableau_titre_valeur_select2[2][1]="01";
tableau_titre_valeur_select2[2][2]="titreA 1";
tableau_titre_valeur_select2[2][3]="02";
tableau_titre_valeur_select2[2][4]="TitreA 2";
tableau_titre_valeur_select2[3]=new Array(5);
tableau_titre_valeur_select2[3][0]="valB";
tableau_titre_valeur_select2[3][1]="10";
tableau_titre_valeur_select2[3][2]="titreB 1";
tableau_titre_valeur_select2[3][3]="15";
tableau_titre_valeur_select2[3][4]="titreB 2";
function reloadList(listfrom, listto, table, defaultvalue, init)
{
if (listfrom.options[listfrom.selectedIndex].value == "")
{
listto.options.length = 1;
listto.options[0].value = "";
listto.options[0].text = "";
}
else
{
for (i=0;i < table.length;i++)
{
if (table[i][0] == listfrom.options[listfrom.selectedIndex].value)
{
beginIndex = 0;
tableCurrent = table[i];
if (defaultvalue)
{
listto.options[0].value = "";
listto.options[0].text = "";
beginIndex = 1;
}
listto.options.length = (tableCurrent.length - 1)/2 + beginIndex;
var sizeTable = tableCurrent.length;
for (j=1; j < sizeTable; j = j + 2)
{
listto.options[(j - 1) / 2 + beginIndex].value = tableCurrent[j];
listto.options[(j - 1) / 2 + beginIndex].text = tableCurrent[j + 1];
}
}
}
if (! init) listto.selectedIndex=0;
}
}
Je vous ai mis le process pour que vous pouvez voir comment ca tourne mais élas je ne peux pas mettre le code réel

dsl mais normalement avec tout ca vous pouvez tester et voir ou je veux en venir ... enfin j espere
Merci en tout cas
heddicmi pour le temps que tu passes avec moi pour résoudre ce problème.
Cependant j'épluche a fond depuis hier TJS et j'ai déja trouver pas mal de piste mais je ne vois pas encore pourquoi mon process ne veut pas marcher j ai planter quelque part mais je vois pas ou ...

je vais vous donner les tableau en plus et normalement avec ca vous aurez tout ...
enfin voilà en gros le process:
Sur la page formulaire :
[code]
<!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" lang="fr" xml:lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" media="screen, projection" href="formulaire.css" />
<script src="control.js" type="text/javascript"></script>
<title>formulaire</title>
</head>
<body>
<form action="<?php echo $action; ?>" method="post">
<select name="nom1" onchange="reloadList(document.forms[0].nom1,document.forms[0].nom2, tableau_titre_valeur_select2, true, false);">
<option value=""> </option>
<option value="valA" >TitreA</option>
<option value="valB" >TitreB</option>
</select>
MON second select
<select name="nom2">
<option value=""> </option>
<option value="val1" >titreA 1</option>
<option value="val2" >titreA 2</option>
</select>
<input type="submit" id="btprecedent" name="valid" value="valider" />
</body>
</html>
[/code]
et dans le fichier control.js:
[code]
tableau_titre_valeur_select2[2]=new Array(5);
tableau_titre_valeur_select2[2][0]="valA";
tableau_titre_valeur_select2[2][1]="01";
tableau_titre_valeur_select2[2][2]="titreA 1";
tableau_titre_valeur_select2[2][3]="02";
tableau_titre_valeur_select2[2][4]="TitreA 2";
tableau_titre_valeur_select2[3]=new Array(5);
tableau_titre_valeur_select2[3][0]="valB";
tableau_titre_valeur_select2[3][1]="10";
tableau_titre_valeur_select2[3][2]="titreB 1";
tableau_titre_valeur_select2[3][3]="15";
tableau_titre_valeur_select2[3][4]="titreB 2";
function reloadList(listfrom, listto, table, defaultvalue, init)
{
if (listfrom.options[listfrom.selectedIndex].value == "")
{
listto.options.length = 1;
listto.options[0].value = "";
listto.options[0].text = "";
}
else
{
for (i=0;i < table.length;i++)
{
if (table[i][0] == listfrom.options[listfrom.selectedIndex].value)
{
beginIndex = 0;
tableCurrent = table[i];
if (defaultvalue)
{
listto.options[0].value = "";
listto.options[0].text = "";
beginIndex = 1;
}
listto.options.length = (tableCurrent.length - 1)/2 + beginIndex;
var sizeTable = tableCurrent.length;
for (j=1; j < sizeTable; j = j + 2)
{
listto.options[(j - 1) / 2 + beginIndex].value = tableCurrent[j];
listto.options[(j - 1) / 2 + beginIndex].text = tableCurrent[j + 1];
}
}
}
if (! init) listto.selectedIndex=0;
}
}
[/code]
Je vous ai mis le process pour que vous pouvez voir comment ca tourne mais élas je ne peux pas mettre le code réel :? dsl mais normalement avec tout ca vous pouvez tester et voir ou je veux en venir ... enfin j espere
Merci en tout cas [b]heddicmi[/b] pour le temps que tu passes avec moi pour résoudre ce problème.
Cependant j'épluche a fond depuis hier TJS et j'ai déja trouver pas mal de piste mais je ne vois pas encore pourquoi mon process ne veut pas marcher j ai planter quelque part mais je vois pas ou ... :cry: