View Full Version : Help me to fix this little javascript problem.
bobbyr
Jun 18th 2007, 10:52 am
Hi Guys
I have this string <a href=javascript:// onClick="changeImageInfo('$listing_url$/images/$file$','$desc$');return false;">
<img src="$listing_url$/images/$thumbnail$"> and when someone add a ' or '' in the description who is describe as $desc$ I have a javascript error. How can I escape the strings, so ' and " become \' and \" .
Bobby
nico_swd
Jun 18th 2007, 11:30 am
www.php.net/addslashes
bobbyr
Jun 19th 2007, 5:32 am
Hi nico
Thanks for your answer but the page is not a php so I can't use it. Anybody else with another solution please?
nico_swd
Jun 19th 2007, 5:38 am
I thought these were PHP variables.
Where does $desc$ come from then? And what is it? Once the Javascript is outputted wrong, there's no way to fix it later. You have to make sure these replacements take place before they're outputted.
bobbyr
Jun 19th 2007, 8:31 am
Hi bro thanks for your answer.
$desc$ is a term in a perl script to show the description that someone give to a picture. Maybe that I need to change it directly in the perl script itself?
If so are you looking for a small job like that if you know perl language?
Let me know
Bobby
nico_swd
Jun 19th 2007, 8:40 am
Sorry, I don't know anything about Perl.
But yes, you will have to apply a function to the variable before outputting it.
bobbyr
Jun 19th 2007, 11:50 am
ok thanks nico do you know any good perl programmer?
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.