Staredit Network

Staredit Network -> Computers and Technical -> Images
Report, edit, etc...Posted by notnuclearrabbit on 2006-03-25 at 06:50:17
[center]
HTML
<p align="center"><a href="http://www.totse.com/"><img src="http://www.totse.com/image/totsead1.gif" alt="& the Temple of the Screaming Electron" align=bottom width=450 height=50 border=0><!-- 1-7 --></a></p>

How would I go about making the image randomized, 1-7, each time you load the page?
Also, for the 'alt="& the Temple of the Screaming Electron"', should I be using an escaped & (&amp;)?
[/center]
Report, edit, etc...Posted by IsolatedPurity on 2006-03-25 at 06:58:15
You can't make things random with pure HTML... you need some type of scripting language like PHP/ASP. Javascript could do it as well but less efficiently. Where no PHP is allowed (it's not your site, like SEN's signatures), you'd need to use your server's htaccess to randomize the file that's being called when one specific file is called.


And yes, &amp; should be in titles/alts... and basically everywhere else as well. But if you were concerned about standards... your code would look a little different, maybe something like this:

CODE
<p style="margin:0 auto 0 auto"><a href="http://www.totse.com/"><img src="http://www.totse.com/image/totsead1.gif" alt="&amp; the Temple of the Screaming Electron" style="width:450;height:50;border:0px;vertical-align:bottom"><!-- 1-7 --></a></p>
Report, edit, etc...Posted by notnuclearrabbit on 2006-03-25 at 07:15:10
[center]Ah well, guess I'll just have to choose my favorite image.
I'm not too concerned about conforming to standards, this isn't for anything public. According to http://validator.w3.org/, "Result: Passed validation"

Krayzie Bone, eh?
[/center]
Report, edit, etc...Posted by Doodle77(MM) on 2006-03-25 at 12:13:47
You can also randomize things with javascript-
CODE

<img src="about:blank" alt="Loading..." id="imgrand">
<script language=javascript>
var numimgs = 3;
document.getElementById('imgrand').src = "www.path.to/image/image" + Math.floor(Math.random() * numimgs) + ".gif"
</script>
Next Page (1)