Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

single quote in middle of name

Status
Not open for further replies.

mevasquez

Programmer
Aug 26, 2003
75
US
I am having a problem trying to escape a "'" character when calling an onClick event. Here is the on click event code.

Code:
strName = oRS.Fields("MEMBER")
response.write "onClick=" & chr(34) & "OpenInfo('" & .Fields("pid") & "','" & strWorkCenter& "','" & strDivision & "','"  & FixApost(strName) & "')" & chr(34)

The FixApost(strName) function code is:
Code:
Function FixApost(pasString)
   Dim tmpString
   Dim iLoc
   tmpString = pasString
   iLoc = InStr(1,tmpString,"'")
   If iLoc > 0 Then
      While iLoc > 0 
          tmpString = Replace(tmpString, "'", "`")
          iLoc = InStr(1,tmpString,"'")
      Wend
    End If
    FixApost = tmpString
End Function

If strname = lname, f'name, it works.
if strname = lname, fna'me, I get an unterminating string error.

How can I keep the unterminating string error from appearing when the single quote is in the middle of a the last name?

TIA
Mike
 
Code:
Function FixApost(pasString)
    If pasString <> "" then
        FixApost = Replace(pasString,"'","\'")
    End If
End Function

Jason

[red]Army[/red] : [white]Combat Engineer[/white] : [blue]21B[/blue]

 
But he is doing this for javascript... to escape a single quote in javascript you put a backslash in front of it, the two single quote thing can be used when inserting into a database...

Jason

Jason

[red]Army[/red] : [white]Combat Engineer[/white] : [blue]21B[/blue]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top