| Author |
Escaping Single Quote (apostrophe )
|
Sam Kumar
Ranch Hand
Joined: Nov 30, 2001
Posts: 38
|
|
Hi, I am trying to escape single-quote but I am getting javascript error. Here is the HTML: <A HREF="javascript:submitForm('SINGLEQUOTE_TEST','Single'Quote');">SingleQuote-Escape Test</A> <BR><BR> <script language="javascript"> function submitForm(a, id){ alert(a); alert(id); } </script> On clicking the link, I am getting following error: Line 1, Char 31, Expected ')' Here actual string is Single'Quote and I am replacing single quote with ' i.e. Single'Quote Any ideas why I am getting javascript error! Thanks in advance! SK
|
 |
Sam Kumar
Ranch Hand
Joined: Nov 30, 2001
Posts: 38
|
|
Oops javaranch replaced "'" with ' while posting. I am puting extra space to avoid conversion. Here is the HTML: <A HREF="javascript:submitForm('SINGLEQUOTE_TEST','Single& #039;'Quote');"> SingleQuote-Escape Test</A> <BR><BR> <script language="javascript"> function submitForm(a, id){ alert(a); alert(id); } </script> Here actual string is Single'Quote and I am replacing single quote with & # 039; ' i.e. Single& # 039;Quote (Ignore extra space) Thanks in advance! SK
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15003
|
|
the center apos is causeing the error in 'Single'Quote' You can do it either 'Single\'Quote' or 'Single'Quote' Eric
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15003
|
|
<A HREF="javascript:submitForm('SINGLEQUOTE_TEST','Single''Quote');"> THis line still has the ' in it afer the &#039; that is the reason why the error appears
|
 |
 |
|
|
subject: Escaping Single Quote (apostrophe )
|
|
|