Rotate messages in a form field (on form load, on focus)

This part goes in the HEAD of the document:
<script LANGUAGE="JavaScript">
var CurrentMsg = 'hello ';
function update(msg) {
var pad_str="";
n = msg.length;
if(n<72) {
pad = (73-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()",4000);
}
function MakeArray(n) {
this.length=n;
for(var i = 1; i<= n; i++) {
this[i] = "";
}
return(this);
}
var index = 1;
var notice_num = 10;
var notices = new MakeArray(notice_num);
notices[1] = "This is message one.";
notices[2] = "This script will show messages in a form field.";
notices[3] = "You can set the number of messages.";
notices[4] = "You can also set the time each message shows.";
notices[5] = "This snippet is old but someone might want it.";
notices[6] = "This is the last message in the list.";
var timer = setTimeout('idleMsg()',5000);
function nochange() {
document.messages.field.value = CurrentMsg;
}
function idleMsg() {
update(notices[index++]);
if(index>notice_num) {
index=1;
}
}
</script>


This part goes in the BODY.
<form name="messages" onSubmit="return false">
<p><input type="text" name="field" size="60" value onFocus="self.status='This is a JavaScript info. field'; return true" onChange="nochange()"></p>
</form>


Back