PDA

View Full Version : Add dropdown to news ticker...



stanbridge
10-17-2007, 05:46 AM
Hi there,

I have used the following script to put a news ticker on my page:

http://www.dynamicdrive.com/dynamicindex2/ajaxticker.htm

Does any body know how I could add a dropdown box that would allow users to "skip" to a specific ticker entry?


I tried adding variations of the following to the ajaxticker.js file:

function statsSelect() {
var statsindex = document.statsForm.SelectedArea.selectedIndex
this.pointer = statsindex;
}... and then calling it via OnChange on my dropdown field/form. No luck. I am a Javascript newbie who has stepped beyond his ability here!

Does anybody know how I could achieve this?

Any help is VERY much appreciated!

Cheers,

Stanbridge

ddadmin
10-17-2007, 11:16 AM
Hmm it's certainly possible, but what do you intend to display within each OPTION's text value to indicate the message it corresponds to? Also, upon jumping to a certain message, did you want the ticker to stop rotating from thereon?

stanbridge
10-17-2007, 11:07 PM
I work for some property research people. They maintain a list of statistical figures for different Cities.

I was planning to use the news ticker more as a statistics ticker - that is, it will roll through a preset list of statistics.

So bascially the "tickercontent.txt" file is going to be a fixed set of data (stats for each City). The options in the dropdown will refer to each set of statistics stored in the <message> divs in tickercontent.

Theoretical Example:

Dropdown
CityA = message[0]
CityB = message[1]
CityC = message[2]
CityD = message[3]


After jumping to a specific message, it would be good if the ticker could pause there and then continue rotating again.

Ideally, the pause would be longer than the usual pause between rotations but if it's too much extra work to make "jumped-to" messages have their own pause time, the normal pause time would suffice.

Any ideas? Is this difficult?

Cheers!

Stanbridge

stanbridge
10-22-2007, 06:07 AM
*bump*


Wow, that was my first time. I've never "bumped" before. :o

ddadmin
10-23-2007, 08:00 AM
Sorry for the delay. Ok, try the attached modified ajaxticker.js. Then, on your page, you would have something like the below:


<script type="text/javascript">

var xmlfile="tickercontent.txt" //path to ticker txt file on your server.

//ajax_ticker(xmlfile, divId, divClass, delay, optionalfadeornot)
var myticker=new ajax_ticker(xmlfile, "ajaxticker1", "someclass", 3500, "fade")
myticker.adddropdown("dropdown", "City ")
</script>

<div id="dropdown"></div>

Notice the part in red, which is new from the default set up. Basically, create a blank div to house the drop down, give it an ID, and pass that into adddropdown(). The second parameter ("City") btw should be the prefix you wish to show in each OPTION's displayed text.