Before starting with the areas of programming, a rule of grammar: the case always, always, always accentuated.
That said, I came across in php if I had a list of options based on a select that I showed the accents correctly. MySQL and php by default use utf-8, so it is good practice to put our html utf-8:
1: \u0026lt;meta http-equiv= "Content-Type" content= "text/html; charset=utf-8" >
However, JavaScript is not used by default utf-8, so when you place a text through document.write, the screen will display the text emphasized as a special character in html (html entity):
1: changecities function ( formObj)
2: { 3: statesObj = eval ( "formObj.states" );
4: 5: state = statesObj[statesObj.selectedIndex].value; 6: citiesObj = eval( "formObj.elements['cities']" );
7: 8: // remove all entries
9: citiesNum = citiesObj.length; 10: for (i=(citiesNum-1); i >= 0; i--)
11: { 12: citiesObj.options[i] = null ;
13: } 14: // add entries based on area selected
15: switch (state){
16: case "3" :
17: citiesObj.options[0] = new Option( "Comondú" ,17);
18: citiesObj.options[1] = new Option ( "La Paz" , 18);
19: citiesObj.options [2] = new Option ( "Loreto" , 19);
20: citiesObj.options [3] = new Option ( "Los Cabos" , 20);
21: citiesObj.options [4] = new Option ( "Mulege" , 21);
22: citiesObj.options [0]. selected = true ;
23: break;
24: 25:} 26: } ... Php is an instruction to turn this character, its value to the character you want:
1: \u0026lt;? Php html_entity_decode ("& # 250" );? >
should result in "ú"
But as we see in the image, select does not display correctly because the instruction html_entity_decode actually results in a character set "ISO-8859- 1 ", so we can choose to do one of two things:
- utf8_encode :
1: \u0026lt;? Php utf8_encode ( html_entity_decode ("& # 250" ));? >
- Change character set option in the instruction html_entity_decode (string, quotestyle, character-set):
Use
1: \u0026lt; ;? Php html_entity_decode ( "&250;" , ENT_COMPAT mode, "UTF-8" )? >
Deployment is:
Ready!