
July 26th, 2004, 12:04 PM
|
|
Registered User
|
|
Join Date: Jul 2004
Posts: 24
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Removing quotes
Hey.
I need a function that will remove single quotes from a string. I have a select box, and I am trying to populate it with JS, but
I can't include some options because they contain quotes. So I wrote a little function that 'should' do the trick...but maybe I'm just
missing something.
Code:
function stripQuotes(word) {
str = word;
while(str.indexOf("'") != -1) {
num = len(str);
str = str.substring(0, str.indexOf("'")-1) + str.substring(str.indexOf("'")+1, num);
}
return str;
}
I then call it in a document.write(stripQuotes("My favorite restaurant is Don's Drive-in."));
But this just throws an error.
Any help out there?
|