Forum de discussion
Forum « Programmation Javascript » (archives)
Compatibilité de script ie5 et ie6
Envoyé: 24 mars 2005, 10h25 par surfeur2
J'utilise un formulaire pour l'inscription des membres de mon site :
Il y a aussi un peu de javascript qui permet de changer le contenu d'une listebox en fonction du choix de l'utilisateur dans une autre listbox.
Par exemple si on choisit la suisse la deuxième listbox change avec le contenu des régions de la suisse.
Le code fonctionne bien avec Internet Explorer 6.0 mais aujourdhui je me suis aperçu qu'in ne fonctionne pas avec Internet Explorer 5.0 !!!
Vous savez comment-faire pour qu'il fonctionne avec les 2 navigateurs ?
Ci-dessous je vous mets le script :
merci d'avance :-)
<script language="javascript">
<!--
function setOption(form, index) {
for (var i = 0; i < form.Region.length; i++) {
form.Region.options[i].text = "";
form.Region.options[i].value = "";
}
if (index == 1) {
form.Region.options[1].text = "Autre";
form.Region.options[1].value = "Autre";
form.Region.options[2].text = "Appenzell";
form.Region.options[2].value = "Appenzell";
form.Region.options[3].text = "Argovie";
form.Region.options[3].value = "Argovie";
form.Region.options[4].text = "Bâle";
form.Region.options[4].value = "Bâle";
form.Region.options[5].text = "Berne";
form.Region.options[5].value = "Berne";
form.Region.options[6].text = "Bienne";
form.Region.options[6].value = "Bienne";
form.Region.options[7].text = "Broye";
form.Region.options[7].value = "Bulle";
form.Region.options[8].text = "Bulle";
form.Region.options[8].value = "Broye";
form.Region.options[9].text = "Chablais";
form.Region.options[9].value = "Chablais";
form.Region.options[10].text = "Echallens";
form.Region.options[10].value = "Echallens";
form.Region.options[11].text = "Fribourg";
form.Region.options[11].value = "Fribourg";
form.Region.options[12].text = "Genève";
form.Region.options[12].value = "Genève";
form.Region.options[13].text = "Glaris";
form.Region.options[13].value = "Glaris";
form.Region.options[14].text = "Grisons";
form.Region.options[14].value = "Grisons";
form.Region.options[15].text = "Gruyère";
form.Region.options[15].value = "Gruyère";
form.Region.options[16].text = "Jura";
form.Region.options[16].value = "Jura";
form.Region.options[17].text = "Jura bernois";
form.Region.options[17].value = "Jura bernois";
form.Region.options[18].text = "Lausanne";
form.Region.options[18].value = "Lausanne";
form.Region.options[19].text = "Les planchettes";
form.Region.options[19].value = "Les planchettes";
form.Region.options[20].text = "Lucerne";
form.Region.options[20].value = "Lucerne";
form.Region.options[21].text = "Payerne";
form.Region.options[21].value = "Payerne";
form.Region.options[22].text = "Portalban";
form.Region.options[22].value = "Portalban";
form.Region.options[23].text = "Neuchâtel";
form.Region.options[23].value = "Neuchâtel";
form.Region.options[24].text = "Rivièra";
form.Region.options[24].value = "Rivièra";
form.Region.options[25].text = "Schwytz";
form.Region.options[25].value = "Schwytz";
form.Region.options[26].text = "Shaffausen";
form.Region.options[26].value = "Shaffausen";
form.Region.options[27].text = "Soleure";
form.Region.options[27].value = "Soleure";
form.Region.options[28].text = "St-Gall";
form.Region.options[28].value = "St-Gall";
form.Region.options[29].text = "Tessin";
form.Region.options[29].value = "Tessin";
form.Region.options[30].text = "Thurgovie";
form.Region.options[30].value = "Thurgovie";
form.Region.options[31].text = "Unterwalden";
form.Region.options[31].value = "Unterwalden";
form.Region.options[32].text = "Uri";
form.Region.options[32].value = "Uri";
form.Region.options[33].text = "Valais";
form.Region.options[33].value = "Valais";
form.Region.options[34].text = "Vaud";
form.Region.options[34].value = "Vaud";
form.Region.options[35].text = "Yverdon";
form.Region.options[35].value = "Yverdon";
form.Region.options[36].text = "Zurich";
form.Region.options[36].value = "Zurich";
form.Region.options[37].text = "Zug";
form.Region.options[37].value = "Zug";
}
else if (index == 2) {
form.Region.options[1].text = "Autre";
form.Region.options[1].value = "Autre";
form.Region.options[2].text = "Alsace";
form.Region.options[2].value = "Alsace";
form.Region.options[3].text = "Aquitaine";
form.Region.options[3].value = "Aquitaine";
form.Region.options[4].text = "Auvergne";
form.Region.options[4].value = "Auvergne";
form.Region.options[5].text = "Basse-Normandie";
form.Region.options[5].value = "Basse-Normandie";
form.Region.options[6].text = "Bourgogne";
form.Region.options[6].value = "Bourgogne";
form.Region.options[7].text = "Bretagne";
form.Region.options[7].value = "Bretagne";
form.Region.options[8].text = "Centre";
form.Region.options[8].value = "Centre";
form.Region.options[9].text = "Champagne-Ardenne";
form.Region.options[9].value = "Champagne-Ardenne";
form.Region.options[10].text = "Corse";
form.Region.options[10].value = "Corse";
form.Region.options[11].text = "Dom-Tom";
form.Region.options[11].value = "Dom-Tom";
form.Region.options[12].text = "Franche-Comté";
form.Region.options[12].value = "Franche-Comté";
form.Region.options[13].text = "Haute-Normandie";
form.Region.options[13].value = "Haute-Normandie";
form.Region.options[14].text = "Ile de France";
form.Region.options[14].value = "Ile de France";
form.Region.options[15].text = "Languedoc Roussillon";
form.Region.options[15].value = "Languedoc Roussillon";
form.Region.options[16].text = "Levallois";
form.Region.options[16].value = "Levallois";
form.Region.options[17].text = "Limousin";
form.Region.options[17].value = "Limousin";
form.Region.options[18].text = "Littoral";
form.Region.options[18].value = "Littoral";
form.Region.options[19].text = "Lorraine";
form.Region.options[19].value = "Lorraine";
form.Region.options[20].text = "Lyon";
form.Region.options[20].value = "Lyon";
form.Region.options[21].text = "Midi-Pyrénées";
form.Region.options[21].value = "Midi-Pyrénées";
form.Region.options[22].text = "Montargis";
form.Region.options[22].value = "Montargis";
form.Region.options[23].text = "Nantes";
form.Region.options[23].value = "Nantes";
form.Region.options[24].text = "Nièvre";
form.Region.options[24].value = "Nièvre";
form.Region.options[25].text = "Nord pas-de-Calais";
form.Region.options[25].value = "Nord pas-de-Calais";
form.Region.options[26].text = "Paris";
form.Region.options[26].value = "Paris";
form.Region.options[27].text = "Pays basque";
form.Region.options[27].value = "Pays basque";
form.Region.options[28].text = "Pays de la loire";
form.Region.options[28].value = "Pays de la loire";
form.Region.options[29].text = "Picardie";
form.Region.options[29].value = "Picardie";
form.Region.options[30].text = "Poitou-Charentes";
form.Region.options[30].value = "Poitou-Charentes";
form.Region.options[31].text = "Prilly";
form.Region.options[31].value = "Prilly";
form.Region.options[32].text = "Provence-Alpes-Côte d'Azur";
form.Region.options[32].value = "Provence-Alpes-Côte d'Azur";
form.Region.options[33].text = "Rhônes-Alpes";
form.Region.options[33].value = "Rhônes-Alpes";
form.Region.options[34].text = "Vienne";
form.Region.options[34].value = "Vienne";
}
else if (index == 3) {
form.Region.options[1].text = "Autre";
form.Region.options[1].value = "Autre";
form.Region.options[2].text = "Anvers";
form.Region.options[2].value = "Anvers";
form.Region.options[3].text = "Bruxelles";
form.Region.options[3].value = "Bruxelles";
form.Region.options[4].text = "Flandres occidentales";
form.Region.options[4].value = "landres occidentales";
form.Region.options[5].text = "Flandres orientales";
form.Region.options[5].value = "Flandres orientales";
form.Region.options[6].text = "Hainaut";
form.Region.options[6].value = "Hainaut";
form.Region.options[7].text = "Brabant";
form.Region.options[7].value = "Brabant";
form.Region.options[8].text = "Liège";
form.Region.options[8].value = "Liège";
form.Region.options[9].text = "Limbourg";
form.Region.options[9].value = "Limbourg";
form.Region.options[10].text = "Luxembourg";
form.Region.options[10].value = "Luxembourg";
form.Region.options[11].text = "Namur";
form.Region.options[11].value = "Namur";
form.Region.options[12].text = "Nivelles";
form.Region.options[12].value = "Nivelles";
}
else if (index == 4) {
form.Region.options[1].text = "Autre";
form.Region.options[1].value = "Autre";
form.Region.options[2].text = "Alberta";
form.Region.options[2].value = "Alberta";
form.Region.options[3].text = "Colombie - Britanique";
form.Region.options[3].value = "Colombie - Britanique";
form.Region.options[4].text = "Île-du-Prince-Edouard";
form.Region.options[4].value = "Île-du-Prince-Edouard";
form.Region.options[5].text = "Labrador";
form.Region.options[5].value = "Labrador";
form.Region.options[6].text = "Manitoba";
form.Region.options[6].value = "Manitoba";
form.Region.options[7].text = "Montrial";
form.Region.options[7].value = "Montrial";
form.Region.options[8].text = "Nouveau-Brunswick";
form.Region.options[8].value = "Nouveau-Brunswick";
form.Region.options[9].text = "Nouvelle-Ecosse";
form.Region.options[9].value = "Nouvelle-Ecosse";
form.Region.options[10].text = "Nunavut";
form.Region.options[10].value = "Nunavut";
form.Region.options[11].text = "Ontario";
form.Region.options[11].value = "Ontario";
form.Region.options[12].text = "Québec";
form.Region.options[12].value = "Québec";
form.Region.options[13].text = "Saskatchewar";
form.Region.options[13].value = "Saskatchewar";
form.Region.options[14].text = "Terre-Neuve";
form.Region.options[14].value = "Terre-Neuve";
form.Region.options[15].text = "Territoire du Nord Ouest";
form.Region.options[15].value = "Territoire du Nord Ouest";
form.Region.options[16].text = "Territoire du Yukon";
form.Region.options[16].value = "Territoire du Yukon";
}
form.Region.selectedIndex = 0;
form.ValueIn2.value = form.Region.options[form.Region.selectedIndex].value;
}
//-->
</script>
Réponses
|