Remove apostrophe from a string
<p>I am working inside a program that allows me reference database fields using syntax such as {Cli:FirstName}, this references the Client's first name. The program allows me to use HTML and java script to display a web page inside a window inside the program. </p>

<p>The problem I am having is that I have written a lot of pages and scripts to display the correct information, but I have found a problem. I have scripts that I pass the database field to a function such as</p>

<pre><code>function a('{Cli:FirstName}'},'{Cli:LastName}'){
logic;
}
</code></pre>

<p>I pass it this way because the function is in an external .js file. The program I am using does not allow me to reference the database field directly except in the .html file that is displaying in the window in the program. Therefore, every function that is in the .js has a similar parameter list. I can write a function in the header of the page and directly access the database field without passing the field as a parameter, but this causes other problems, and I moved almost all the scripts out due to speed and other limits in the program that is displaying the web page.</p>

<p>The problem occurs when I try to pass a database field that has an apostrophe in it to a function in the.js file. It crashes the function call, since the apostrophe is a string delimiter. Some of the functions are event driven, but some are also when the page loads. The order of operations is that the program does the database query first, and then renders the html following normal flow for web pages. When, I load a page and a field has an apostrophe in it, and that is in a function call, I get an error message. Example Name: is O’Malley would crash the script.
I need to fix it so after the database query is complete, I can go through the fields that I use as parameters in the functions and escape the apostrophe   /’ before I pass into a function.</p>

<p>My first thought is write a function on the html page, therefore I can access the database field directly and then escape the apostrophe, and then pass that value to the other functions. This way the apostrophe removal function would be generic enough to work for any other of the fields with apostrophes. I need help on how to write the function and then pass that functions result to another function.</p>

<pre><code>function removeApostrophe (){
var firstName = ‘{CLI:FirstName}’; // sets the variable equal to the string in the database
  // do this for each field I use as a parameter in other functions
}
</code></pre>
