Link to home
Start Free TrialLog in
Avatar of lantervj
lantervjFlag for United States of America

asked on

Removing apostrophes from a string

Pretty simple stuff.  I just don't see the problem.  If I remove all ScanLastName code it works (remove spaces).

        var scandoc = '';
      var ScanDoc1 = '';
      var ScanDocFileName = '';
      var ScanLastName = "212227_O'Connell".replace(/'/g, '');
      var TheDivToRefresh = '';

function btnScan_onclick(divToRefresh)
{
    ScanDoc1 = $('input.scandocument').val();
    ScanDoc = ScanDoc1.replace(/\s/g, '');
    ScanDocFileName = ScanDoc+ScanLastName;
}
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Escape your filename :
function btnScan_onclick(divToRefresh)
{
    ScanDoc1 = $('input.scandocument').val();
    ScanDoc = ScanDoc1.replace(/\s/g, '');
    ScanDocFileName = escape(ScanDoc+ScanLastName);
}
Avatar of lantervj

ASKER

I get btnScan_0nclick is undefined.  If I remove all ScanLastName code it works fine.
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It was caused by another statement;

$("div.filenameClass").html("The file name will be:   '+str+'_#indivnum#_#lastname#.pdf');

I had to change the escape apostrophes with quotes.  The pound signs are Coldfusion variables. The new statement is;

$("div.filenameClass").html("The file name will be:   "+str+"_#indivnum#_#lastname#.pdf".replace(/'/g, ''));