Support Forum Softcomplex logo
About Us  | Services  | Download  | Order  | Support  | |
| Search | Today's Posts | Stats | Board Rules | Not logged in [ Login | Register ]
go to bottom
Last active: Never

Printable Version | Subscribe | Add to Favourites   Post new thread
Author: Subject: show random fragments of the HTML code
tigra
Administrator

Posts: 2049
Registered: 6/17/2002
Location: US, CO
Member Is Offline
posted on 7/11/2005 at 06:35 PM Reply With Quote
show random fragments of the HTML code


/* list all items */
var a_items = [
'<img src="images/1.gif">',
'<img src="images/2.gif">',
'<img src="images/3.gif">',
'<img src="images/4.gif">',
'<img src="images/5.gif">',
'<img src="images/6.gif">',
'<img src="images/7.gif">',
'<img src="images/8.gif">'
];

function randomize (a_items, n_count) {
var n_index, s_html = '<table cellpadding="0" cellspacing="1" border="0"><tr>';
while (a_items.length && n_count) {
n_index = Math.ceil(Math.random() * a_items.length) - 1;
s_html += '<td>' + a_items[n_index] + '</td>';
a_items[n_index] = a_items[a_items.length - 1];
a_items.length = a_items.length - 1;
n_count--;
}
return s_html + '</tr></table>';
}

// call randomizer
// param 1 - list of items
// param 2 - number of items to display
document.write(randomize (a_items, 3));

Attachment: randomizer.zip (5.15kb)
This file has been downloaded 1364 times
View User's Profile View All Posts By User U2U Member
Post new thread

Related Links:

Go To Top


Powered by XMB 1.9.1 Nexus
Developed By Aventure Media & The XMB Group © 2002-2004