Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

single / double quote problem

Status
Not open for further replies.

KryptoS

Programmer
Feb 7, 2001
240
BE
Hello,

I have to following line in my code:

href = "<a href=\"#\" onclick=\"javascript:document.getElementById(' "+getInput+" ').value=' "+city+" ';\">";

All is working fine. Only in some cases I have a city value like = 's City. So href gets the value something like this = .value=' 's City';\">"; You see the problem with the 's.

I tried to replace the ' by \' in city. city.replace(" ' "," \' ");. But it didn't have any effect.

thanks for your help.

Greetings

p.s. I placed some spaces between ' and " to make it more clear

The One And Only KryptoS
 
You need to double slash it (not a technical term).
Code:
...
city.replace("'","[!]\[/!]\'");
...

Cheers,
Jeff

[tt]Jeff's Blog [!]@[/!] CodeRambler
[/tt]

Make sure your web page and css validates properly against the doctype you have chosen - before you attempt to debug a problem!

FAQ216-6094
 
That will only work if the path you are going to has the apostrophe in it, you may need to remove it or replace it with a different character.


-Sometimes the answer to your question is the hack that works
 
sorry I didn't let you know something. This is working fine. Thanks a lot. I'm always getting confused by those quotes...

The One And Only KryptoS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top