View Full Version : scrolling text box with time limits on subjects?

01-30-2006, 10:33 PM
I have a client who wants to have a "calendar of events" scrolling box. She also wants to have a set time limit...when the date of the event is over, the item is automatically deleted from the scrolling calendar. :confused: And if that's not enough, she also wants to be able to easily change and add new events. This sounds like a lot to me, but I'm a uber-newbie. I already have the JS for the scrolling text box. Thanks in advance!

02-02-2006, 09:17 PM
Hey, anyone out there who can even tell me if this is possible at all would be greatly appreciated! Anyone? Some genius?

02-03-2006, 06:32 AM
Possible, yes. How much is your client willing to pay for this? Anyways, one would start with or create a scrolling type thing (many free examples of which are in the DD script library and elsewhere on the web). Now, some of these type scripts work off of an array of entries. This array could be made multidimensional and an entry in each entry's array could be the expiration date. Those that have expired could be culled using a test against the current date (either on the server or user's machine), prior to the array's use by the rest of the script to populate the scroller. Example of plain array to populate a scroller (from Pausing up-down message scroller (http://www.dynamicdrive.com/dynamicindex2/crosstick.htm)):

//configure the below variable to change the contents of the scroller
var messages=new Array()
messages[0]="<font face='Arial'><a href='http://www.dynamicdrive.com'>Click here to go back to Dynamicdrive.com frontpage</a></font>"
messages[1]="<font face='Arial'><a href='http://javascriptkit.com'>Visit JavaScriptKit for award winning JavaScript tutorials</a></font>"
messages[2]="<font face='Arial'><a href='http://www.codingforums.com'>Get help on scripting and web development. Visit CodingForums.com!</a></font>"
messages[3]="<font face='Arial'><a href='http://www.freewarejava.com'>Looking for Free Java applets? Visit Freewarejava.com!</a></font>"
messages[4]="<font face='Arial'><a href='http://dynamicdrive.com/link.htm'>If you find this script useful, please click here to link back to Dynamic Drive!</a></font>"

Now the array can be made multidimensional using this technique (additions red):

messages[0]=["<font face='Arial'><a href='http://www.dynamicdrive.com'>Click here to go back to Dynamicdrive.com frontpage</a></font>", "5/25/2006"]

With that change, everywhere in the script that used to use messages[0] (messages[x]), for the content of the message would now need to use messages[0][0] (messages[x][0]), and so on for the rest of the entries. An expiration date can be set for each entry (an empty field could be used for no expiration, but would have to be tested for as well as the date then). To add entries is simple, they just get tacked onto the end of the array and to remove entries before displaying them, if they have expired, can be accomplished by testing messages[x][1] against the current date and using the splice() method, removing them before populating the scroller. It would be a good idea to periodically remove expired entries but, this could be done at one's leisure. Entries would need to maintain consecutive number sequence (when added and especially when removed) for the array to be valid for use by the script.

02-10-2006, 07:41 PM

Thanks for the info. Sorry 'bout the delay. They haven't sent even as much as copy or anything else to me yet, but you can bet they'll want it done in two days when it gets here.

Hope I can figure out what you said! Like I mentioned, I'm an old graphics guy, and the only codes I know are some VERY basic html, and zip codes!:)

02-10-2006, 08:13 PM
Once you get some code post your best shot or, better yet put up a working or non-working demo and supply a link. In addition to the methods and means I outlined above, you will need to use the new Date() object and some of the date object's get methods, like .getDate() and .getMonth(), etc. to craft a string to compare to the date entry in the message array entries.