I'm populating an array with string labels taken from a db.
Unfortunately the labels may contain characters such as the apostrophe
and the backslash so when I create the array:
myArray = [];
myArray.push('<%= str1 %>');
myArray.push('<%= str2 %>');
....
I can get javascript errors because the generated code contains lines
like this:
myArray.push('This is Andrew's page');
I have no control of the data in the db.
The strings get displayed in the page so they have to look "right".
I don't want to create a separate case for each "invalid" character.
What's the best way to handle this so that "invalid" characters are
handled correctly?
Andrew Poulos