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 3 of 3
  1. #1
    New Coder
    Join Date
    Dec 2006
    Posts
    80
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Simple Javascript Ticker & Line Breaks

    Hi,

    I have a script that ticks error messages from an SQL database query. Here is the script:

    function errorTick()
    {
    p1.style.visibility = "visible" //make the div visible
    errStr = errCatch.value //errCatch is a hidden field which is fed the error
    if (i == errCatch.value.length)
    {
    p1.style.pixelWidth = 500 //set a width to work with in the next function
    shrinkErr()//call shrinkErr

    }
    else
    {

    p1.innerHTML+=errStr.charAt(i) //read each letter from the error (supposed to convert into HTML, but because of charAt still reads as string)
    i+=1//go up one
    window.setTimeout("errorTick()", 50)//start again
    }



    }

    function shrinkErr()
    {
    var myTimer
    var counter = p1.style.pixelWidth//This will equal 500px (set in above script)
    if (counter ==480)//minimum pixelWidth
    {
    window.clearTimeout(myTimer)//Stop
    }

    else
    {
    p1.style.pixelWidth-=5//SHrink 5 pixels at a time
    myTimer = window.setTimeout("shrinkErr()", 50)//start again
    }
    }

    The shrinkErr function is what I'm trying to avoid. It basically shrinks the div containing the error into the display area where I want the error to be displayed. The div is about 20 pixels too wide, when the longest error occurs. Is there a way to add a <BR> in there somewhere? I've tried adding the <BR> into the hidden field and then sending it into the errStr variable and then into the div through the innerHTML method. But it still reads the <BR> as a string, any ideas why, or what I can do here?

    Help much appreciated.
    Joe

  • #2
    Senior Coder Arbitrator's Avatar
    Join Date
    Mar 2006
    Location
    Splendora, Texas, United States of America
    Posts
    3,372
    Thanks
    32
    Thanked 286 Times in 280 Posts
    Is there a reason that the text can’t wrap normally?
    For every complex problem, there is an answer that is clear, simple, and wrong.

  • #3
    New Coder
    Join Date
    Dec 2006
    Posts
    80
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Hi,

    Thanks for getting back to me.

    I'm not sure, do you want some markup?

    Cheers
    Joe


  •  

    Posting Permissions

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