...

View Full Version : Simple Javascript Ticker & Line Breaks



LFCFan
01-05-2007, 10:18 AM
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

Arbitrator
01-05-2007, 10:47 PM
Is there a reason that the text canít wrap normally?

LFCFan
01-09-2007, 10:05 AM
Hi,

Thanks for getting back to me.

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

Cheers
Joe



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum