WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Random Image
Categories : Java Script, Graphics
Boaz Yahav
Date : Aug 29th 1998
Grade : 3 of 5 (graded 11 times)
Viewed : 7210
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Boaz Yahav
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

Include random.txt in the HEAD section of you document.
Add a function call inside your document:

<script language="javascript">
<!---
RandomImage("dog2-small.gif condo-view-small.gif hiking1-small.gif hiking2-
small.gif malanda-small.gif snowball-small.gif snowcamping-small.gif spider1-
small.gif spider3-small.gif ");
// --->
</script>
<br>


random.txt
==========
<SCRIPT language="javascript">
<!-- Image Selector
// Cameron Gregory - cameron@bloke.com
// http://www.bloke.com/
// http://www.bloke.com/javascript/Random/
// http://www.bloke.com/javascript/Random/link.html
// This line and about must remain .. then you can use it for free...
//
// ChangeLog
//
//
// Sat Sep 21 16:36:47 EDT 1996
// Added associate URL list.
//
// Fri Sep 13 18:36:20 EDT 1996
// Created from the base of Selector()
//
// Usage:
// RandomImage(images)
// RandomImageLong(images,iparams)
// RandomImageLink(images,urls)
// RandomImageLinkLong(images,urls,iparams)
// images is space or comma separated file list
// urls is space or comma separated list of url's
// iparams params to add to <img>

function RandomImageLong(images,iparams)
{
/* si: start index
** i: current index
** ei: end index
** cc: current count
*/
si = 0;
ci=0;
cc=0;
imageSet = new Array();
ei = images.length;
for (i=1;i<ei;i++) {
if (images.charAt(i) == ' ' || images.charAt(i) == ',') {
imageSet[cc] = images.substring(si,i);
cc++;
si=i+1;
}
}
ind = Math.floor(Math.random() *cc);
document.writeln("<img "+iparams+" src="+imageSet[ind]+" alt=\""+imageSet[ind]
+"\">");
}

function RandomImage(images)
{
RandomImageLong(images," ");
}

function RandomImageLinkLong(images,urls,iparams)
{
/* si: start index
** i: current index
** ei: end index
** cc: current count
*/
imageSet = new Array();
urlSet = new Array();
si = 0;
ci=0;
cc=0;
ei = images.length;
for (i=1;i<ei;i++) {
if (images.charAt(i) == ' ' || images.charAt(i) == ',') {
imageSet[cc] = images.substring(si,i);
cc++;
si=i+1;
}
}
ind = Math.floor(Math.random() *cc);
si = 0;
ci=0;
cc=0;
ei = urls.length;
for (i=1;i<ei && cc <=ind ;i++) {
if (urls.charAt(i) == ' ' || urls.charAt(i) == ',') {
urlSet[cc] = urls.substring(si,i);
cc++;
si=i+1;
}
}

//document.writeln("<img "+iparams+" src="+imageSet[ind]+" alt=\""+imageSet
[ind]+"\">");
document.writeln("<a href=\""+urlSet[ind]+"\"><img "+iparams+" src="+imageSet
[ind]+" alt=\""+imageSet[ind]+"\"></a>");
}

function RandomImageLink(images,urls)
{
RandomImageLinkLong(images,urls,"border=0");
}

// End Script -->
</SCRIPT>



This is a script that list all image files on a given directory, and displays the thumbnails nicely formated within an HTML table. It also make use of JavScript to open pop up windows when the users want to see the full photo.
Categories : Graphics, PHP, Complete Programs, Java Script
Image Flipper
Categories : Java Script, Graphics
JAVASCRIPT interface class to the eBusiness Charts generatation remote service.
Categories : Java Script, Graphics, Charts and Graphs
A ball is attached to your mouse cursor with an elastic cord!
Categories : Java Script, DHTML, Graphics
Create Thumbnails - resize an image - jpeg, jpg, gif, png to the specifed width and height in proportion without loosing out on pixcel quality.
Categories : PHP, GD image library, Graphics
Zephyr: AJAX Based Framework for PHP5 Developers
Categories : PHP, AJAX, Frameworks, Java Script, Web Applications
Create HTML forms dynamicly using Javascript & PHP
Categories : PHP, PHP Classes, Java Script
AJAX XML HTTP Request - Compatible with almost browsers!
Categories : AJAX, HTTP, Java Script
javascript doesn't accept a fieldname with []
Categories : Java Script
Array values from javascript to php
Categories : PHP, Java Script, Arrays
Linked comboboxes with php-mysql & javascript
Categories : PHP, Java Script, Databases, MySQL
Random Image Display
Categories : PHP, Filesystem, Graphics, HTML and PHP
The toll booth
Categories : PHP, Java Script, Filesystem
MD5 secured login
Categories : PHP, Java Script, Authentication, Security
Flash Detection Script with loads of features
Categories : Java Script, Flash