waltmayo Posted November 6, 2013 Report Share Posted November 6, 2013 Simple script... checks a field value... if not blank, it ".writes" the value to HTML... if it is blank, it uses the data from a different field. If the variable value has an apostrophe in it, the whole thing returns a blank string. It obviously breaks the code. There are many reference to this type of thing on the web, but NONE of the solutions I've tried have worked. Below is a sample, including code to escape the apostrophe with a "\" character. Doesn't work... HELP! <script> var X='[@field:Event_Name_Override]'; var Y='[@field:Event_Name]'; X = X.replace(/\'/g, ""); Y = Y.replace(/\'/g, ""); if (X.length>1) { document.write(X); } else { document.write(Y); } </script> Quote Link to comment Share on other sites More sharing options...
ShWolf Posted November 11, 2013 Report Share Posted November 11, 2013 Hi, Replace single quotes with double quotes in these rows: var X='[@field:Event_Name_Override]'; var Y='[@field:Event_Name]'; Let me know if this helps. Quote Link to comment Share on other sites More sharing options...
kRv Posted November 22, 2013 Report Share Posted November 22, 2013 Simple script... checks a field value... if not blank, it ".writes" the value to HTML... if it is blank, it uses the data from a different field. If the variable value has an apostrophe in it, the whole thing returns a blank string. It obviously breaks the code. There are many reference to this type of thing on the web, but NONE of the solutions I've tried have worked. Below is a sample, including code to escape the apostrophe with a "\" character. Doesn't work... HELP! If your data can contain and apostrophe and double quotes, you can write value to some hidden field in HTML block, and read value in script later. It is more right way, because it will work in both cases. But if you just want avoid "apostrophe issue", you can use variant offered above. Quote Link to comment Share on other sites More sharing options...
Kurumi Posted February 29 Report Share Posted February 29 Hi! Just wanted to share this solution if you want to read or accept the single quote or apostrophe (') in the formula: https://stackoverflow.com/questions/9596652/how-to-escape-apostrophe-a-single-quote-in-mysql Example: Replace([@field:FIELDNAME], 'Can''t found the name', 'Remove name') Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.