私はすべての国のイメージを持っていますが、ビジュアルに言語の名前の前にイメージを追加するにはどうすればいいですか?基本的には、各選択肢に国旗が表示されます。あなたの助けてくれてありがとう、これは私ができるほど詳細です。この選択リストに画像を追加するにはどうすればよいですか? Javascript?
<body>
<header>
<div id="country-select">
<form action="" method="get">
<select id="locale" name="locale">
<option value="none">Select A Language</option>
<option value="en_US">English(US)</option>
<option value="en_GB">English(UK)</option>
<option value="bg_BG">Bulgarian</option>
<option value="cs_CS">Czech</option>
<option value="da_DK">Danish</option>
<option value="de_DE">German</option>
<option value="ek_GR">Greek</option>
<option value="es_ES">Spanish</option>
<option value="et_ET">Estonian</option>
<option value="fi_FI">Finnish</option>
<option value="fr_FR">French</option>
<option value="hu_HU">Hungarian</option>
<option value="it_IT">Italian</option>
<option value="lt_LT">Lithuanian</option>
<option value="lv_LV">Latvian</option>
<option value="nl_NL">Dutch</option>
<option value="no_NO">Norwegian</option>
<option value="pl_PL">Polish</option>
<option value="pt_PT">Portugese</option>
<option value="ro_RO">Romanian</option>
<option value="sk_SK">Slovak</option>
<option value="sl_SL">Slovenian</option>
<option value="sv_SE">Swedish</option>
</select>
<input value="Select" type="submit" />
</form>
</div>
</header>
<script>
//Main Function: creates the page dynamically & switches the url to selected country
function GetSelectedItem() {
var option = document.getElementById("locale").value;
}
\t
\t //Main Function: Split the string of the URL
\t function getParameterByName(name, url) {
\t \t //Retrieves website URL
\t \t if (!url) url = window.location.href;
\t \t //Replaces the 1st parameter with the 2nd parameter
\t \t name = name.replace(/[\[\]]/g, "\\$&");
\t \t //Takes all the regular expressions and results is the value we need
\t \t var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), results = regex.exec(url);
\t \t //If empty or none are in there return Null
\t \t if (!results) return null;
\t \t //If the URL name doesn't have anything in index 2 return empty stress
\t \t if (!results[2]) return '';
\t \t //Return the value without the regular expressions.
\t \t return decodeURIComponent(results[2].replace(/\+/g, " "));
\t }
\t
\t //Set variable to the splitted string (e.g. en_GB would be the value inside of the getParameterByName()
\t var localeVariable = getParameterByName('locale');
\t //Make the drop down menu stay on the country selected
\t var temp = localeVariable;
\t //Determine with for loop to go through each country with the countring variable j
\t for(var i, j = 0; i = locale.options[j]; j++){
\t //if value matches go in the if to make the value the selected index
\t \t if(i.value == temp){
\t \t \t //set whatever j equaled to the selected index.
\t \t \t locale.selectedIndex = j;
\t \t \t break; //Break if value matches
\t \t }
\t }
\t
</script>
</body>
この回答を参照してください:http://stackoverflow.com/questions/2965971/how-to-add-a-images-in-select-list –
@MagnusBuvarpありがとう、試してみましたが、うまく動作しませんでした。 – Giorgio