Description:
This JavaScript allows you to display messages in a text box.
JavaScript Functions: <SCRIPT LANGUAGE="JavaScript"> <!--- Begin 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] = "Welcome to JavaScript Search!"; notices[2] = "You can fill this box with any message you like"; notices[3] = "As you can see, it is quite easy"; notices[4] = "to provide messages to the users of your site."; notices[5] = "using this JavaScript"; var timer = 0; function nochange() { document.messages.field.value = CurrentMsg; } function idleMsg() { update(notices[index++]); if(index>notice_num) { index=1; } } // End --> </SCRIPT>
HTML Script: <FORM name="messages" onSubmit="return false"> Click <INPUT TYPE=BUTTON VALUE="Start" onclick="timer = setTimeout('idleMsg()',4000);"><br> <input type="text" name="field" size=73 value="" onFocus="self.status='This is a JavaScript info field'; return true" onChange="nochange()"> </FORM>