Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jun 2002
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Escape character for single quote problem

    I keep getting a script error when I enter a string like this

    quotes[9]='This is what I\'m trying to say'

    Why doesn't this work? Every webpage I've seen says this works, but I get a script error every time.

    TIA,
    Reuben

  • #2
    New to the CF scene
    Join Date
    Jun 2002
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    damm, there was supposed to be a backslash in the string, right before the single quote. The board must have parsed it out.

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    Northern NJ
    Posts
    404
    Thanks
    0
    Thanked 1 Time in 1 Post
    why not just go between quotes and double quotes like so

    quotes[9] = "This is what I'm trying to say"

    make sure you have your language parameter, set " \' " should work. next time just post your code.
    I would rather be a lion for a day than a lamb that lives forever.

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    41 8' 52" N -95 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Are you getting this error when you're displaying the information on a page, or when you're writing it to a database?

    There are easy solutions for both situations!
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #5
    New to the CF scene
    Join Date
    Jun 2002
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi all,

    I'm getting this problem when writing to a div marker within a webpage. I'll paste the entire code below. The problem is that block of quotes[] assignments. When I put either single quote within a double quote assignment like
    quotes[0]="He's a dog." or when I use a single quote within a single quote assignment, like this
    quotes[0]='He\'s a dog." I get a script error. If I remove the single quote, it works fine.

    Thanks

    <!--
    var secs
    var timerID = null
    var timerRunning = false
    var delay = 1000
    var quotes=new Array()
    var whichquote
    var tempwhich

    quotes[0]='everything is purple.'
    quotes[1]='we kill Jesus again.'
    quotes[2]='the chickens inherit the Earth.'
    quotes[3]='it turns out the Jews were right.'
    quotes[4]='the lotto numbers are 21 5 3 25 33 17.'
    quotes[5]='dogs WILL play poker.'
    quotes[6]='Reubeeeeen ****s a like, totally cantankerous bovine carny.'
    quotes[7]='Cheez-Itz is people.'
    quotes[8]='iguanas are everywhere.'
    quotes[9]='Sony owns everybodys reproductive organs.'
    quotes[10]='America finally kicks Canadas ***.'
    quotes[11]='\"smell ya later\" does indeed replace \"Goodbye\".'

    function writetoLyr(id, message)
    {
    if (document.layers)
    {
    document.layers[id].document.write(message)
    document.layers[id].document.close()
    }
    else if (document.all)
    {
    eval("document.all."+id+".innerHTML='"+message+"'")
    }
    else
    {
    document.getElementById(id).innerHTML = message;
    }
    }

    function InitializeTimer()
    {
    // Set the length of the timer, in seconds
    secs = 4
    StopTheClock()
    StartTheTimer()
    }

    function StopTheClock()
    {
    if(timerRunning)
    clearTimeout(timerID)
    timerRunning = false
    }

    function StartTheTimer()
    {
    if (secs==0)
    {
    StopTheClock()
    PrintAMessage()
    }
    else
    {
    //self.status = secs
    secs = secs - 1
    timerRunning = true
    timerID = self.setTimeout("StartTheTimer()", delay)
    }
    }

    function PrintAMessage()
    {
    writetoLyr('testLayer','')
    while(tempwhich==whichquote)
    {
    tempwhich=Math.floor(Math.random()*(quotes.length))
    }
    whichquote=tempwhich
    setTimeout("WriteIt()",500)
    InitializeTimer();
    }

    function WriteIt()
    {
    writetoLyr('testLayer',quotes[whichquote])
    }

    function StartItOff()
    {
    whichquote=Math.floor(Math.random()*(quotes.length))
    tempwhich=whichquote
    writetoLyr('testLayer',quotes[whichquote])
    InitializeTimer()
    }

    function makevisible(cur,which){
    strength=(which==0)? 1 : 0.2

    if (cur.style.MozOpacity)
    cur.style.MozOpacity=strength
    else if (cur.filters)
    cur.filters.alpha.opacity=strength*100
    }

    //-->
    </SCRIPT>


    </html>


  •  

    Posting Permissions

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