PDA

View Full Version : Random start page in Featured Content Glider?



WaxonWaxov
04-17-2008, 04:19 PM
1) Script Title: Featured Content Glider

2) Script URL (on DD): http://dynamicdrive.com/dynamicindex17/featuredcontentglider.htm

3) Describe problem: This script is exactly what I need. I have but one question: Let's say I have 20 sets of conent for the script. Is there a way to tell the script to start on a randomly selected page?

OK, I lied I have an additional question related to the first... Is there a way to add a 'random' buttion in addition to the 'next' and 'previous buttons'?

Thanks a lot. I just found this site recently. I was good at html 10 years agoi and now I am trying to catch up. I have learned a lot from this site.

ddadmin
04-17-2008, 06:38 PM
The first part is very simple. Within your initialization code, simply change the following line in red to the below:


featuredcontentglider.init({
gliderid: "canadaprovinces", //ID of main glider container
contentclass: "glidecontent", //Shared CSS class name of each glider content
togglerid: "p-select", //ID of toggler container
remotecontent: "", //Get gliding contents from external file on server? "filename" or "" to disable
selected: Math.floor(Math.random()*3), //Default selected content index (0=1st)
"
"

In other words, instead of an integer like 0, change it to Math.floor(Math.random()*3), where 3 should be the total number of contents you have within the glider.

Regarding the 2nd question, the script currently doesn't expose any public methods for easily jumping to a particular slide unfortunately.

tonyking
04-17-2008, 09:46 PM
It is possible to add a "random" effect to this script. To do so you would need to basically just refresh the content, and the random attribute would do its job nicely.

I would accomplish this by placing the entire script inside of a div, and creating a button that onclick only refreshed the contents of that div. It would look kind of trashy if the whole page reloaded. You just make the button say "random" and no one knows the difference.

WaxonWaxov
04-18-2008, 12:29 AM
thanks a lot to both people.

As far as telling a button to refresh a <div> please give me the code...

Like I said I was good at all this ten years ago, I am a noob at this dhtml stuff...:)

If I get this thing to work it will be exactly what I need.