473,326 Members | 2,134 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

displaying Japanese text with new Option does not work

1
Hello I have function that generates a list op options for a select dropdown box

here is the function
I am pretty sure that the problem is situated in the new Option() function
Expand|Select|Wrap|Line Numbers
  1. function showKens(){
  2.         var kenList = document.form1.ken;
  3.         var cityList = document.form1.city;
  4.         var kenId = kenList.options[kenList.selectedIndex].value;
  5.         var cityName = '';
  6.         cityList.options.length = 0;
  7.         i = 0;
  8.         for (y in ken_array[kenId].city){
  9.             cityName = ken_array[kenId].city[y];
  10.             cityList.options[i] = new Option(cityName, y);
  11.             i++;
  12.         }
  13.     }
  14.  
if I try to hard code a japanese city name in the new Option() function
Expand|Select|Wrap|Line Numbers
  1. cityList.options[i] = new Option('福岡', y);
  2. is displayed like 福岡 
  3. instead of 福岡
  4.  
cityList.options[i] = new Option('福岡', y);

the name is not displayed correctly because the & is changed into &

does anyone know how to make sure Javascript does not change the value of the & into &

Here is the complete function (mix of php and javascript)
Expand|Select|Wrap|Line Numbers
  1. function new_location_edit($city01, &$dbread, $time, $default_language)
  2. {
  3.     $userlang_ken="KenNameLan_".$_SESSION['userlanguage'];
  4.     $defaultlang_ken="KenNameLan_".$default_language;
  5.     $userlang_city="CityNameLan_".$_SESSION['userlanguage'];;
  6.     $defaultlang_city="CityNameLan_".$default_language;;
  7. //    echo "userlang: ".$userlang_ken;
  8.     $TableName1 = 'ken';
  9.     $TableName2 = 'city';
  10.     //$Query is the query that select the list of prefecture ordered by name
  11.     $QuerySelectKen = "SELECT $TableName1.* 
  12.                         FROM $TableName1 
  13.                         WHERE KenId <> 1
  14.                         order by $userlang_ken ASC, $defaultlang_ken ASC;";
  15.     echo $QuerySelectKen . '<BR>';
  16.     $Result1= $dbread->CacheGetAll($time,$QuerySelectKen);
  17.     foreach($Result1 AS $Row1){
  18.         if($Row1[$userlang_ken]==null){
  19.             $kens[($Row1['KenId'])]['name'] = $Row1[$defaultlang_ken];
  20.         }else{
  21.             $kens[($Row1['KenId'])]['name'] = $Row1[$userlang_ken];
  22.         }
  23.  
  24. //        $kens[($Row1['KenId'])]['name'] = $Row1['KenNameLan_1'];
  25.         $QuerySelectCity = "SELECT $TableName2.* 
  26.                             FROM $TableName2 
  27.                             WHERE $TableName2.KenId = $Row1[KenId]
  28.                             OR $TableName2.KenId = '0'
  29.                             ORDER BY CityNameLan_1 ASC;";
  30. //        echo $QuerySelectCity . '<BR>';
  31.         $Result2 = $dbread->CacheGetAll($time,$QuerySelectCity);
  32.         foreach($Result2 AS $Row2){
  33.             if($Row2[$userlang_city]==null){
  34.                 //echo "<br />".$Row2['CityId']."null";
  35.                 $kens[($Row1['KenId'])]['city'][($Row2['CityId'])] = $Row2[$defaultlang_city];
  36.             }else{
  37. //                echo  "<br />".$Row2['CityId'].": ".$Row2[$userlang_city]." ".$Row2[$defaultlang_city];
  38.                 $kens[($Row1['KenId'])]['city'][($Row2['CityId'])] = $Row2[$userlang_city];
  39.             }
  40.         }
  41.     }
  42.     //get the ken and city for this user
  43.     if($city01!=null){    
  44.         $QuerySelectKenCity = "SELECT $TableName2.*, $TableName1.KenNameLan_1
  45.                                 FROM $TableName2 
  46.                                 LEFT JOIN {$TableName1} ON {$TableName2}.KenId = {$TableName1}.KenId 
  47.                                 WHERE $TableName2.CityId = $city01;";
  48.     }else{
  49.         //echo "city = null";
  50.         $QuerySelectKenCity = "SELECT $TableName2.*, $TableName1.*
  51.                                 FROM $TableName2 
  52.                                 LEFT JOIN {$TableName1} ON {$TableName2}.KenId = {$TableName1}.KenId 
  53.                                 WHERE $TableName2.CityId = 1;";
  54.  
  55.     }
  56. //    echo $QuerySelectKenCity;
  57.     $Row3 = $dbread->CacheGetRow($time,$QuerySelectKenCity);
  58.     //echo "KEN: ".$Row3['KenNameLan_1'].$Row3['KenId'];
  59.     //echo "CITY: ".$Row3['CityNameLan_1'].$Row3['CityId'];
  60.  
  61.     print <<<LLL
  62.     <script language="Javascript" type="text/javascript">
  63.     <!--
  64.     function showKens(){
  65.         var kenList = document.form1.ken;
  66.         var cityList = document.form1.city;
  67.         var kenId = kenList.options[kenList.selectedIndex].value;
  68.         var cityName = '';
  69.  
  70.         cityList.options.length = 0;
  71.  
  72.         i = 0;
  73.         for (y in ken_array[kenId].city){
  74.             cityName = ken_array[kenId].city[y];
  75.             cityList.options[i] = new Option(cityName, y);
  76.             i++;
  77.         }
  78.     }
  79.     var ken_array = new Array();
  80. LLL;
  81.     foreach ($kens as $kenId=>$kenDetails){
  82.         $kenName = $kenDetails['name'];
  83.         print <<<LLL
  84.  
  85.         ken_array[$kenId] = new Array();
  86.         ken_array[$kenId].name = '$kenName';
  87.         ken_array[$kenId].city = new Array();
  88. LLL;
  89.         foreach ($kenDetails['city'] as $cityId=>$city){
  90.             print <<<LLL
  91.  
  92.             ken_array[$kenId].city[$cityId] = '$city';
  93. LLL;
  94.         }
  95.     }
  96.     print <<<LLL
  97.  
  98.     document.write('<select name="ken" onchange="showKens()">');
  99. LLL;
  100.     if($Row3[$userlang_ken]==null){
  101.         print <<<LLL
  102.         document.write('<option value="$Row3[KenId]">$Row3[$defaultlang_ken]</option>');
  103. LLL;
  104.     }else{
  105.         print <<<LLL
  106.         document.write('<option value="$Row3[KenId]">$Row3[$userlang_ken]</option>');
  107. LLL;
  108.     }
  109.     print <<<LLL
  110.     for (var i in ken_array){
  111.         document.write('<option value="'+i+'">'+ken_array[i].name+'</option>');
  112.     }
  113.     document.write('</select>');
  114.     document.write('<input name="kenname" type="hidden" value="$Row3[KenNameLan_1]" />');
  115. LLL;
  116.     if($Row3[$userlang_city]==null){
  117.         print <<<LLL
  118.         document.write('<select name="city"><option value="$Row3[CityId]">$Row3[$defaultlang_city]</option></select>');
  119. LLL;
  120.     }else{
  121.         print <<<LLL
  122.         document.write('<select name="city"><option value="$Row3[CityId]">$Row3[$userlang_city]</option></select>');
  123. LLL;
  124.     }
  125.     print <<<LLL
  126.     document.write('<input type="hidden" name="cityname" value="$Row3[CityNameLan_1]" />');
  127.     -->
  128.     </script>
  129. LLL;
  130. }
  131.  
  132. Thank you for looking
  133.  
  134. anatak
  135.  
Jan 21 '07 #1
1 1645
iam_clint
1,208 Expert 1GB
&amp; is the same as &

the &amp; is the html equivilent and is used for query strings usually such as GET or POST in a form.


cityList.options[i] = new Option('福岡', y);

is displayed like &amp;#31119;&amp;#23713;
instead of 福岡

in this i don't even see an & or &amp; in your new option?
Jan 22 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Jim E. | last post by:
Using VC++ on an application for English Win 95/98 thru XP, how can I display multi-byte characters (Asian languages or roman characters with accent marks) in standard MFC controls like CEdit,...
1
by: Sriv Chakravarthy | last post by:
I am trying to use xerces-c SAX parser to parse japanese characters. I have a <?xml... utf-8> line in the xml file. When the parser encounters the jap characters it throws a UTFDataFormatException....
3
by: Benoit Martin | last post by:
in my windows app, I have some japanese text that I load from a text file and display on a label. No matter what type of encoding I try to use on the text file, the text always comes up as a bunch...
7
by: Daniel | last post by:
I`m trying to show japanese characters in an alert, like; alert('実装されていませ'); This doesn't work as shown in this post:...
4
by: Thorben | last post by:
Hello group, does anybody knows a way to add Japanese language to a western language based application? Our software is switch-able between English and France. Now I got the job to add...
11
by: prats | last post by:
I want to write a GUI application in PYTHON using QT. This application is supposed to take in Japanese characters. I am using PyQt as the wrapper for using QT from python. I am able to take input...
1
by: bjs | last post by:
I am using MS SQL Server 2000 and 2005, IIS 5,0 and ASP. I am able to display data that has been selected from a Unicode column in the database in all languages except Japanese (I get question...
11
by: pardesiya | last post by:
Friends, I am having trouble displaying Japanese text within a textbox (or anywhere else) in an aspx page with .net 2.0 framework. Initial default text in Japanese displays perfectly but when I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.