Tuesday, July 31, 2012

asp.net – Single Quote in Javascript Param



I have a function that, when clicked, fills in a field of the parent window. In this case, it\’s a name (text) field.


The problem I\’m having is if the field has a single quote in it (ex. Bill\’s Chili) the function fails because it reads the single quote as the end of the parameter.


Here is the call:



href=\"javascript:selectItem(\'recipe\',\'recipe_name\',\'<recipe_description\')\"


Again, if the name is Bill\’s Chili, it causes a syntax error.


Is there a way to automatically convert that single quote to the HTML equivalent so it will read properly?


Thanks






Rating: 3 out of 5 based on 5 ratings



The post asp.net – Single Quote in Javascript Param appeared first on Javascript ASK.






via Javascript ASK http://javascriptask.phpfogapp.com/asp-net-single-quote-in-javascript-param.html

No comments:

Post a Comment