In javascript, i know it is possible to use and manipulate strings. I looked into the string object, but it doesen’t have just plain ol’ text, always bold, italic, etc. So, i need to use somthing like goes into a document.write, a string in quotes, that i can access at any time.
I have a marquee that i am working on, using the DOM, i am scrolling it in a 1-row table. Each cell in the single row is identified by a base followed by a number (so that more than one of these could be on a page).
The function scroll(mx, base, id, msg) is used to put the message into the table.
mx – the maximum cell number for the table, cells starting at 1
base – the base name for the cells
id – the number for an array containing the starting character
msg – the string representation of the message to scroll
the function goes like this:
var chararray = new Array();
[code]
function scroll(mx, base, id, msg)
{
var x = 0;
var c = 0;
//increment the current character
chararray[id]++;
//put it into a variable we can change a bunch
c = chararray[id];
//loop once for each cell
for(x = 1; x < mx; x++)
{
//test if the current character number is too big; fix the problem
if c > msg.length
c = 0;
//put the character into the current cell
document.getElementById(base + x).firstChild.data = msg[c];
}
}
Now, this should, in theory, fill a table like this:
[ ][ ][ ][ ][ ][ ][ ][ ][ ][1]
[ ][ ][ ][ ][ ][ ][ ][ ][1][2]
[ ][ ][ ][ ][ ][ ][ ][1][2][3]
[ ][ ][ ][ ][ ][ ][1][2][3][ ]
as long as 2 things are true:
1. chararray MUST be persistent between calls to the function
2. in the last statement, (base + x) comes out as a string
so, is there a way to make chararray persistent between calls?
and, does (base + x) come out as a string?