I have a page with a set of featured clients with business descriptions (they include text and often an image). I'd like to find a script that will allow me to randomize those, so that each time the page is refreshed, they have an equal opportunity to be at the top of the page. Is this possible? Javascript would be best for the host I'm using.
Thanks for the reply wolfshade. I appreciate the help! I figured it might be, but I'm limited to javascript. No, no database. The customer descriptions are just coded onto the page...
Oh dear. Thank you, MrHoo for your reply. I'm not sure I know how to make a list work with my page. Would it help to see the page I questioning about? This is the page: http://www.small-business-consulting...usinesses.html
Right now, I have each business just alphabetized and separated with a <hr>.
Would your list example work here?
To reiterate, if it's at all possible, I'd like all of the businesses to stay visible on the page and just rotate or randomly re-order each time the page is refreshed, so they all have an opportunity to get to the top of the page.
1. get a reference to the parent element of the items to be rotated
2. create an array who's members are those you want re-ordered
3. randomize the array
4. append each member of the array to the parent- they will be moved to the end of the parent in a random order or
If the parent contains items that are not to be moved, you can use parent.replaceChild(item, olditem),
but it would be simpler for you to contain them all in a div or list or some other container.
Swapping items requires you to keep track of the item that is replaced.
Bookmarks