Reply to Re: inserting random photo with caption

Your name:

Reply:


Posted by dorayme on 01/02/06 01:17

In article <1136039700_213@corp.com>,
carolyn <cajunk@marenger.com> wrote:

> I am looking for a script that can load a random photo or other graphic into
> a web page. The trick is that I would also like it to load a related
> caption with the image.
>
> I have found lots of scripts that will load random photos, and also ones
> that will load random text. I have not found any that can load text
> related to a random photo. I may have to hone my programming skills and
> merge some scripts to do what I would like, however I am hoping that
> someone already has done the work and is making it available to the world.

Had this problem myself once and wrote a whole lot of conditional
(one for each pic) in the js. Basically I did this:

In the head I put:

<script language="JavaScript" type="text/javascript">
<!-- Hide this script from old browsers
var random = Math.random() ;
var picnum = Math.round(random*9)+1;

// End Hiding Here -->
</script>

In the place I wanted the pic, in the body of the html, I wrote:

<script language="JavaScript" type="text/javascript">
<!-- Hide this script from old browsers
document.write('<a href=index.html><img src=pic'+picnum+'.jpg
border=0></a>')
document.write('</td><td>')

if (picnum==1) {document.write("<blockquote>Site visit to a
province in China to assess a plant for making waste plastic into
synthetic diesel fuel, which was tested on the spot in an
all-purpose vehicle</blockquote>")}

if (picnum==2) {document.write("<blockquote>Client inspects
operation of vortex in hydrocyclone wax melting tank during
development stages using water<blockquote>")}

etc etc


// End Hiding Here -->
</script>

I named my pics like this so the conditionals could catch them:

pic1.jpg
pic2.jpg

etc

(I had about 12 pics)

Amazing. All my own work and it will be laughed at by all and
sundry no doubt as being a bit amateurish. but it worked as far
as I and the client could test....

dorayme

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация