Bonjour à tous,

J'ai récupéré je ne sais plus où un script de sélection de la langue avec un drapeau pour changer de langue dans la page php.
Il fonctionne bien mais il y a un petit bug. C'est toujours l'anglais qui reste affiché même si la langue est bien changé.
Comment puis-je le modifier pour afficher le drapeau sélectionné?
Merci d'avance.

Voici mon code html
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<!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" />
	<script src="scripts/jquery-1.4.2.min.js" type="text/javascript"></script>
    <script src="scripts/languageswitcher.js"></script> 
<title>Untitled Document</title>
<style type="text/css">
#country-select {
	position: absolute;
	top: 15px;
	right: 25px;
	width: 130px;
	}
 
/* rought form styles for when JS is disabled */
 
#country-select form {
	width: 130px;
	padding: 0;
	}
 
#country-select select,
#country-select input {
	display: inline;
	padding: 0;
	margin: 0;
	}
/* JS-created definition list */
 
.dropdown dd { position: relative; }
 
.dropdown a {
	text-decoration: none;
	outline: 0;
	font: 12px Arial, Helvetica, sans-serif;
	display: block;
	width: 130px;
	overflow: hidden;
	}
 
.dropdown dt a {
	background: #003466;
	border: 1px solid #000;
	padding: 3px 10px 4px 10px;
	-webkit-border-radius: 5px;
	-moz-border-radius: 5px;
	border-radius: 5px;
	color: #fff;
	}
 
	.dropdown dt a.active {
		background: #003466;
		-webkit-border-bottom-left-radius: 0;
		-webkit-border-bottom-right-radius: 0;
		-moz-border-radius-bottomleft: 0;
		-moz-border-radius-bottomright: 0;
		border-bottom-left-radius: 0;
		border-bottom-right-radius: 0;
		border-bottom: 1px dotted #676768;
		-moz-box-shadow: 0 3px 7px rgba(0,0,0,.5);
		-webkit-box-shadow: 0 3px 7px rgba(0,0,0,.5);
		box-shadow: 0 3px 7px rgba(0,0,0,.5);
		color: #fff;
		}
 
.dropdown dd ul {
	border: 1px solid #676768;
	color: #fff;
	display: none;
	position: absolute;
	z-index: 999;
	top: 0;
	left: 0;
	padding: 2px 0 5px 0;
	list-style: none;
	border-top: none;
	margin: 0;
	-webkit-border-bottom-right-radius: 5px;
	-webkit-border-bottom-left-radius: 5px;
	-moz-border-radius-bottomright: 5px;
	-moz-border-radius-bottomleft: 5px;
	border-bottom-right-radius: 5px;
	border-bottom-left-radius: 5px;
	-moz-box-shadow: 0 3px 7px rgba(0,0,0,.5);
	-webkit-box-shadow: 0 3px 7px rgba(0,0,0,.5);
	box-shadow: 0 3px 7px rgba(0,0,0,.5);
	background-color: #003466;
	}
 
	.dropdown dd ul li a {
		padding: 2px 10px;
		}
 
	.dropdown dd ul li a span,
	.dropdown dt a span {
	float: left;
	width: 16px;
	height: 11px;
	margin: 2px 6px 0 0;
	background-image: url(../images/flags.png);
	background-repeat: no-repeat;
	cursor: pointer;
		}
 
		.uk a span { background-position: 0 0 }
		.fr a span { background-position: -16px 0 }
		.it a span { background-position: -32px 0 }
		.es a span { background-position: -48px 0 }
		.de a span { background-position: -64px 0 }
 
	.dropdown dd ul li a em,
	.dropdown dt a em {
		font-style: normal;
		float: left;
		width: 100px;
		cursor: pointer;
		}
 
	.dropdown dd ul li a em {
		color: #fff;
		}
 
		.dropdown dd ul li a:hover { background-color: rgba(255,255,255,.1); }
		.dropdown dd ul li a:hover em { color: #fff; }
</style></head>
 
<body>
 
<div id="help"><div id="country-select">
  <form action="">
    <select id="country-options" name="country-options">
      <option selected="selected" title="index.php?lang=uk" value="uk">English</option>
      <option title="index.php?lang=fr" value="fr">français</option>
      <option title="index.php?lang=it" value="it">italiano</option>
    </select>
    <input value="Select" type="submit" />
  </form>
</div>
</div>
</body>
</html>
et le script
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
$(document).ready(function() {
 
	// --- language dropdown --- //
 
	// turn select into dl
	createDropDown();
 
	var $dropTrigger = $(".dropdown dt a");
	var $languageList = $(".dropdown dd ul");
 
	// open and close list when button is clicked
	$dropTrigger.toggle(function() {
		$languageList.slideDown(200);
		$dropTrigger.addClass("active");
	}, function() {
		$languageList.slideUp(200);
		$(this).removeAttr("class");
	});
 
	// close list when anywhere else on the screen is clicked
	$(document).bind('click', function(e) {
		var $clicked = $(e.target);
		if (! $clicked.parents().hasClass("dropdown"))
			$languageList.slideUp(200);
			$dropTrigger.removeAttr("class");
	});
 
	// when a language is clicked, make the selection and then hide the list
	$(".dropdown dd ul li a").click(function() {
		var clickedValue = $(this).parent().attr("class");
		var clickedTitle = $(this).find("em").html();
		$("#target dt").removeClass().addClass(clickedValue);
		$("#target dt em").html(clickedTitle);
		$languageList.hide();
		$dropTrigger.removeAttr("class");
	});
});
 
	// actual function to transform select to definition list
	function createDropDown(){
		var $form = $("div#country-select form");
		$form.hide();
		var source = $("#country-options");
		source.removeAttr("autocomplete");
		var selected = source.find("option:selected");
		var options = $("option", source);
		$("#country-select").append('<dl id="target" class="dropdown"></dl>')
		$("#target").append('<dt class="' + selected.val() + '"><a href="#"><span class="flag"></span><em>' + selected.text() + '</em></a></dt>')
		$("#target").append('<dd><ul></ul></dd>')
		options.each(function(){
			$("#target dd ul").append('<li class="' + $(this).val() + '"><a href="' + $(this).attr("title") + '"><span class="flag"></span><em>' + $(this).text() + '</em></a></li>');
			});
	}