Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Display different image on homepage

  • 22-10-2005 8:43pm
    #1
    Closed Accounts Posts: 297 ✭✭


    I want to display a different picture on the homepage, everytime someone visits the homepage. I am using dreamweaver and I am sh ite at HTML.


Comments

  • Closed Accounts Posts: 7,145 ✭✭✭DonkeyStyle \o/


    There are a lot of ways of doing it, but I'd say the easiest way is to google for a free javascript that'll do it.
    Then all you have to do is copy & paste it into the html with only a few basic modifications needed.


  • Closed Accounts Posts: 8,478 ✭✭✭GoneShootin


    If you have access to a MySQL database you could use the RAND() function to return a truly random image each time a page is loaded.


  • Closed Accounts Posts: 7,145 ✭✭✭DonkeyStyle \o/


    Well... there's easy and there's tidy ;)


  • Closed Accounts Posts: 8,478 ✭✭✭GoneShootin


    Mine's both :D


  • Registered Users, Registered Users 2 Posts: 1,268 ✭✭✭hostyle


    Mine's both :D

    You call adding the extra overhead of using a database for something this simple "tidy and simple" ? :)

    How about putting all the images (for our example we'll use 5) named masthead_01.jpg to masthead_05.jpg in an images/ sub-directory. We'll use PHP for this example, but something similar can be achieved just as easily in most languages.

    [php]
    <img src="images/masthead_0<?php $random = rand(1,5); echo $random; ?>.jpg" />
    [/php]


  • Advertisement
  • Closed Accounts Posts: 8,478 ✭✭✭GoneShootin


    hostyle wrote:
    You call adding the extra overhead of using a database for something this simple "tidy and simple" ? :)

    Compared to messy aul Javascript or DHTML yes. But I like your solution too :)


  • Closed Accounts Posts: 7,145 ✭✭✭DonkeyStyle \o/


    Mine's both :D
    Well keep in mind the OP admits to a pretty poor knowledge of html... so I doubt there's any sql or php knowledge there either... 'easy' is a pretty relative term.
    Compared to messy aul Javascript or DHTML yes.
    There shouldn't be anything really that messy about a JS that'll do this... using something like document.write on the client side to achieve basically what hostyle's example does on the server side.
    It's a good enough way of doing it if you've only got the most basic of hosting. (ie. no server side scripting at all)
    And of course it's not really accessable, but for a beginner the page is probably not going to be in the first place.
    Although certainly use hostyles example if you can.


  • Registered Users, Registered Users 2 Posts: 166,026 ✭✭✭✭LegacyUser


    There are a lot of ways of doing it, but I'd say the easiest way is to google for a free javascript that'll do it.
    Then all you have to do is copy & paste it into the html with only a few basic modifications needed.

    your best bet


Advertisement