Rotating Text Banner


 
Copy this code into your head <head></head> tag. You can make the rotation of the test fast by increasing the number 5000 in the line: timer = setTimeout("idleMsg()",5000); 

<script language="JavaScript">
<!-- Hide from old browsers
// Copyright  1999 Doug Popeney
// Created by Doug Popeney (easyjava@easyjavascipt.com)
// JavaScript Made Easy!! - http://www.easyjavascript.com

function update(msg) {
        var pad_str="";
        n = msg.length;
        if(n<81) {
                pad = (81-n)/2;
                for(var i=0; i<pad; i++) {
                        pad_str+=" ";
                }       
        }       
        CurrentMsg = pad_str + msg;
        document.messages.field.value = CurrentMsg;
        clearTimeout(timer);
        timer = setTimeout("idleMsg()",5000);
}       
function MakeArray(n) {
        this.length=n;
        for(var i = 1; i<= n; i++) {
                this[i] = "";
        }
        return(this);
}
var index = 1;
var notice_num = 4;
var notices = new MakeArray(notice_num);
notices[1] = "MESSAGE #1";
notices[2] = "MESSAGE #2";
notices[3] = "MESSAGE #3";
notices[4] = "MESSAGE #4";
// var timer = setTimeout('idleMsg()',);

function idleMsg() {
        update(notices[index++]);
        if(index>notice_num) { index=1; }
}

// -->
</script>
Now put this where ever you want in your HTML document 

<form name="messages" onSubmit="return false">
<input type="text" name="field" size=45  height=5 value="">
</form>
To add more messages, change the number 4 in the line var notice_num = 4; to the number of messages that you have. Then add the line 

notices[5] = "MESSAGE #5";

