View Full Version : Quotes in a name

06-25-2009, 12:20 PM
I am dynamicaly creating a hyper link, to call a javascript function, passing a name from a database into the function.
It all works until the name such as 'Hamish D'Sa' which has a ' in it, where the link then produces a syntax error because of the unmatched quotes.
How do I code for this.
The failing link is link is
<a href="javascript:showtickets(1,'Hamish D'Sa')">View Tickets</a>

06-25-2009, 12:58 PM
I have this working now.
I replaced the ' in the name with %# in the link, and then replaced %# with '' (2 single quotes) as the sql required the name to be 'Hamish D''Sa' to correctlt process the query.

06-25-2009, 01:15 PM
<a href="#" onclick="showtickets(1,'Hamish D\'Sa');return false;">View Tickets</a>