Solved

apostrophe in Javascript array

Posted on 2003-12-12
2
1,327 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
2 Comments
 
LVL 12

Accepted Solution

by:
ahosang earned 200 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

It's sometimes a bit tricky to use date functions in Oracle BPEL. I'll explain quickly how you can add N days to the current date. In a BPEL process this can be useful, and you can adapt it to fit your needs. First of all, let's see how to add 1 …
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now