Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

apostrophe in Javascript array

Posted on 2003-12-12
2
Medium Priority
?
1,384 Views
Last Modified: 2012-06-27

Hi

I have a javascript array that i use to populate combo boxes on my asp page. The string values i have in there may occasionally contain apostrophes such as the Italian town shown below.

MyArray[0][1] = new Option('Citta Sant'Angelo area');

However this causes errors as the array gets confused with the apostrophe in the string and thinks that it represents the end of the string.

In VB you can do a Replace(MyString, " ' ", " ' ' ") to fix this sort of problem on sql inserts etc...

Is there something similar i can do in Javascript as it is not preferable to simply remove the apostrophes.

Many thanks in advance

Kels
0
Comment
Question by:Kels
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 12

Accepted Solution

by:
ahosang earned 800 total points
ID: 9927840
You can do it in the form:
MyArray[0][1] = new Option("Citta Sant'Angelo area");

or:
MyArray[0][1] = new Option('Citta Sant\'Angelo area');
0
 

Author Comment

by:Kels
ID: 9927853
Actually i had just found that myself, i didn't realise you could use double quotes.

Thanks
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question