...

View Full Version : Quotes in a name



Hamishrock
06-25-2009, 11:20 AM
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
[code]
<a href="javascript:showtickets(1,'Hamish D'Sa')">View Tickets</a>

Hamishrock
06-25-2009, 11:58 AM
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.

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum