开发者

Escape apostrophe in my jsp

Hello i have this code in my jsp

<a href="#"onclick="supprimerProduit('<bean:write name="gererProduitsForm"  property="type_produit.nomProduit"/>','supprimerProduit','',<bean:write name="gererProduitsForm"  property="type_produit.idProduit"/>)"></a>

So i have an javascript error when i have for example

T开发者_StackOverflow社区homa's

in my var

<bean:write name="gererProduitsForm"  property="type_produit.nomProduit"/>

How can i do for escape the apostrophe..? Thx


@brandizzi: This subject is different from the other one you linked to. Escaping an apostrophe on a db insert/update, or stripping an apostrophe on db select is a horse of a different color. Escaping an apostrophe in a url string, like the example in the original post here is a whole different kettle of wax.

To Mercer, this is my recommendation for escaping the apostrophe in a url string: Replace ' with %27

The javascript way to do it is like this:

my_title = "Who's to say we aren't all a dream?";

my_title = my_title.replace("'", "%27");

The PHP way to do it is:

$my_title = "Who's to say we aren't all a dream?";

$my_title = str_replace("'","%27",my_title);

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜