473,651 Members | 2,792 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem display foreign characters in javascript country/region dropdown ...

Initially the form is loaded using ASP and HTML and the ü codes
display the characters correctly. I have the values stored in a
javascript array so that I can more easily and dynamically change the
state/region dropdown when the country changes. However, when my
javascript code tries to add the new option and print out new region
the literal value such as "Würrtember g" is displayed instead of
the special character.

Can this be done in javascript?
(I saw a previous old question about this, but no reply.)

Thanks.
Melissa Mussitsch

Oct 16 '06 #1
6 3835
Initially the form is loaded using ASP and HTML and the ü codes
display the characters correctly. I have the values stored in a
javascript array so that I can more easily and dynamically change the
state/region dropdown when the country changes. However, when my
javascript code tries to add the new option and print out new region
the literal value such as "Würrtember g" is displayed instead of
the special character.
Hi Melissa,

the HTML entities like ü are not properly evaluated by the JavaScript
interpreter when assigning them as values of option items. This may be
browser dependent.
You can try to encode the values as hex unicode codepoints. In the example,
this would be W\u00FCrrtember g. (By the way, the correct spelling is
"Württember g" with one r and two t. It's close to where I live ;-)
It should be fairly easy to parse the contents of your array, detect the
entities and replace them with the equivalent unicode hex code. Or simply
hard-code them, doesn't matter as long as they are not loaded from a DB.

Hope this helps,

Leo
Oct 16 '06 #2


On Oct 16, 4:12 pm, "Leo Meyer" <leomeyer_LIKES _NO_S...@gmx.de wrote:
Initially the form is loaded using ASP and HTML and the ü codes
display the characters correctly. I have the values stored in a
javascript array so that I can more easily and dynamically change the
state/region dropdown when the country changes. However, when my
javascript code tries to add the new option and print out new region
the literal value such as "Würrtember g" is displayed instead of
the special character.Hi Melissa,

the HTML entities like ü are not properly evaluated by the JavaScript
interpreter when assigning them as values of option items. This may be
browser dependent.
You can try to encode the values as hex unicode codepoints. In the example,
this would be W\u00FCrrtember g. (By the way, the correct spelling is
"Württember g" with one r and two t. It's close to where I live ;-)
It should be fairly easy to parse the contents of your array, detect the
entities and replace them with the equivalent unicode hex code. Or simply
hard-code them, doesn't matter as long as they are not loaded from a DB.

Hope this helps,

Leo
Leo,

Thank you so much for your response. I think this gets me closer and
at least I know I'm not losing my mind!
However, do you know of a formula to convert the HTML entity to the
unicode hex code? I didn't find anything in my search and know in my
instance that the number of characters I need to convert is too many to
hard-code. I was testing with the JavaScript charCodeAt function but
don't think this is getting me what I need and I don't fully understand
unicode versus unicode hex versus ascii and then html entities, etc.
It gets very confusing to me.

Thanks.
Melissa

Oct 17 '06 #3


On Oct 16, 10:46 pm, "Melissa" <melissa.mussit ...@ansys.comwr ote:
On Oct 16, 4:12 pm, "Leo Meyer" <leomeyer_LIKES _NO_S...@gmx.de wrote:


Initially the form is loaded using ASP and HTML and the ü codes
display the characters correctly. I have the values stored in a
javascript array so that I can more easily and dynamically change the
state/region dropdown when the country changes. However, when my
javascript code tries to add the new option and print out new region
the literal value such as "Würrtember g" is displayed instead of
the special character.Hi Melissa,
the HTML entities like ü are not properly evaluated by the JavaScript
interpreter when assigning them as values of option items. This may be
browser dependent.
You can try to encode the values as hex unicode codepoints. In the example,
this would be W\u00FCrrtember g. (By the way, the correct spelling is
"Württember g" with one r and two t. It's close to where I live ;-)
It should be fairly easy to parse the contents of your array, detect the
entities and replace them with the equivalent unicode hex code. Or simply
hard-code them, doesn't matter as long as they are not loaded from a DB.
Hope this helps,
LeoLeo,

Thank you so much for your response. I think this gets me closer and
at least I know I'm not losing my mind!
However, do you know of a formula to convert the HTML entity to the
unicode hex code? I didn't find anything in my search and know in my
instance that the number of characters I need to convert is too many to
hard-code. I was testing with the JavaScript charCodeAt function but
don't think this is getting me what I need and I don't fully understand
unicode versus unicode hex versus ascii and then html entities, etc.
It gets very confusing to me.

Thanks.
Melissa- Hide quoted text -- Show quoted text -

Leo - actually I think I've realized that I need to convert my html
entity decimal value to hex. parseInt is not working the way I want it
to at the moment, but I'll work through that. I think I'm just tired!

Thanks.
Melissa

Oct 17 '06 #4

"Melissa" <me************ ***@ansys.comsc hrieb im Newsbeitrag
news:11******** *************@m 73g2000cwd.goog legroups.com...
Thank you so much for your response. I think this gets me closer and
at least I know I'm not losing my mind!
Take it easy ;-)
>Leo - actually I think I've realized that I need to convert my html
entity decimal value to hex. parseInt is not working the way I want it
to at the moment, but I'll work through that. I think I'm just tired!
It's fairly simple. You could define a function that takes a string.
Get the position of an HTML entity ("&#").
If found (position -1), append characters up to this position to the
result variable.
Collect characters up to the next ";" or the end of the string.
Check that the characters are in fact a number.
Convert the number to hex, prefix with 0's if necessary. Append to the
output.
Remove chars from the input string up to the end of the entity.
Repeat until no more entities can be found.
Return the result string.

Such type of string parsing is fairly common practice. Unfortunately, it is
rarely taught. If you can't get it to work, post your code here, and we'll
se what we can do ;-)

Leo
Oct 17 '06 #5
Melissa wrote:
Initially the form is loaded using ASP and HTML and the ü codes
display the characters correctly. I have the values stored in a
javascript array so that I can more easily and dynamically change the
state/region dropdown when the country changes. However, when my
javascript code tries to add the new option and print out new region
the literal value such as "Würrtember g" is displayed instead of
the special character.
alert ('Schöne Mädchen in Würtemburg!'
.replace(/(&)(#)(\d{1,})( ;)/g,
function (tot,amp,cr,cp, sem) {
return String.fromChar Code(cp)
}
)
)

--
Bart

Oct 17 '06 #6


On Oct 17, 4:56 am, "Bart Van der Donck" <b...@nijlen.co mwrote:
Melissa wrote:
Initially the form is loaded using ASP and HTML and the ü codes
display the characters correctly. I have the values stored in a
javascript array so that I can more easily and dynamically change the
state/region dropdown when the country changes. However, when my
javascript code tries to add the new option and print out new region
the literal value such as "Würrtember g" is displayed instead of
the special character. alert ('Schöne Mädchen in Würtemburg!'
.replace(/(&)(#)(\d{1,})( ;)/g,
function (tot,amp,cr,cp, sem) {
return String.fromChar Code(cp)
}
)
)

--
Bart
Thank you so much! This worked like a charm!!

Melissa

Oct 17 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
11432
by: Smash | last post by:
i have this function: ------------------------------------------------------------ function isAlfaNumeric(vnos,space) { if (space==false) { validRegExp = /^{0,}$/; } else { validRegExp = /^{0,}$/; }
0
1701
by: WebHouse.Co | last post by:
Hi Sir I'm in my 2nd year in M.Sc. degree & I made a project about the powerful tools SQLXML 3.0 & updategram, so I made a list of programs which r they so similar to the example that using updategram with ASP That exist in the documentation of the Microsoft SQL Server XML Tools as the following page: Sample ASP Application
2
1604
by: ddaniel | last post by:
I have read many posts and seen many papers on the different techniques for sort and filtering datagrids. Many do re-queries against the dB ala Fritz Onion. I am trying to leverage the Dataview. The following control simply responds to a sort request and/or a pageing reqeust with an empty table (header only). Any ideas ? Code behind : namespace OakTree.data {
2
4545
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was set to...it is set to false. Can someone show me what I am doing wrong and tell me the correct way? Thank you. In the page load event, I am doing the following:
0
1435
by: annivanova | last post by:
Hi, I saw posts in Dependent listboxes on access forms, which problem is very similar to my. I’m working over to create an MS Access application. I used in my project given code : Code: Private Sub Country_AfterUpdate() With Me! If IsNull(Me!Country) Then ' if no country is selected .RowSource = "" ' leave row source of Region blank
17
2646
by: Navodit | last post by:
So I have some code like: if (document.Insurance.State.selectedIndex == 1) { ifIll(); } else if (document.Insurance.State.selectedIndex == 2) { elseKan(); }
1
3749
by: skyson2ye | last post by:
Hi, guys: I have written a piece of code which utilizes Javascript in PHP to create a three level dynamic list box(Country, States/Province, Market). However, I have encountered a strange problem, and I have spent three days trying to debug but to no avail. Everything is OK when there are only two dependent list boxes, but when adding the third child list box, a problem appears: if I populate the third box only with the value: new...
2
2213
coolv
by: coolv | last post by:
Hello I have problem in my page that the dropdown box is not displaying data according to selection of first dropdown.Please help me. Below is my code. thanks.............. <?php session_start(); if (!isset($_SESSION)) {
2
2520
by: swethak | last post by:
Hi, i am getting the problem when i used the onclick event in option tag.It is working fine in mozilla .But it is not working IE. Here is my code <script>
0
8352
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8802
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8697
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8465
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7297
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5612
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4283
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1909
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1587
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.