Results 1 to 3 of 3

Thread: how to handle single quotes

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2002
    Posts
    145

    how to handle single quotes

    Hi all,

    I'm fairly new to javascript. Just started to learn today. I'm having an error due to this single quotes. The string I'm passing contains single quotes. What I wanted is to have it 'escaped' so that it will pass the same value. I wanted to retain its original value.

    For example, my string contains MEN'S SHOES. I understand that this should be passed as MEN\'S SHOES. But my string is in a variable. I now can get the location of the (') using indexof. The problem is how to insert the backslash.

    Please help me.

  2. #2
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    If it's in a variable why do you need to re-escape it? But if you need to split strings up you can use "string".substring(from, to) to get a section of a string.

  3. #3
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    indexof "'"

    double single double ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width