SHORT VERSION OF QUESTION: So basically my question is: How can I set the javascript to use UTF-8 so that å ä ö are supported, so my javascript can add the correct values to the drop list options?
LONGER EXPLANATION: Im using javascript to fill 'options' in a drop down list on my main page. The drop down lists are in a form which calls a php script, which querys a mysql database.
The problem is, Im using special characters such as å ä ö in my mysql database. And when I query the mysql database like this:
SELECT * FROM database WHERE city = $city
bir şey bulmak değildir.
This because $city contains special characters set by the javascript. But if setting the $city variable without javascript, for example in my html document with
option value=åäö
sonra çalışacaktır. Bu javascript sorun anlamına gelir ve bunun yerine başka bir şey için özel karakterleri belirler, ve bu bir şey bulmak için değil, sorgu yapar.
Benim damla aşağı liste doldurur javascript:
if(document.nav_form_main.nav_city_list.value == '4'){
removeAllOptions(document.nav_form_main.nav_city_list);
addOption(document.nav_form_main.nav_city_list, "Göteborg", "Göteborg", "");
addOption(document.nav_form_main.nav_city_list, "goteborg_closeby", "Angränsande områden", "");
addOption(document.nav_form_main.nav_city_list, "1", "Hela Sverige", "");
addOption(document.nav_form_main.nav_city_list, "other_area", "-- Välj område på nytt --", "");
}
function removeAllOptions(selectbox)
{
var i;
for(i=selectbox.options.length-1;i>=0;i--)
{
//selectbox.options.remove(i);
selectbox.remove(i);
}
}
function addOption(selectbox, value, text )
{
var optn = document.createElement("OPTION");
optn.text = text;
optn.value = value;
selectbox.options.add(optn);
}
MY HTML ANA BELGE KULLANIMI: ISO 8859-1
WHEN ECHOING "ÅÄÖ" it works in my PHP code. BUT WHEN ECHOING THE VARIABLE FROM THE JAVASCRIPT THE ÅÄÖ IS REPLACED BY WEIRD SYMBOLS