3 Replies Latest reply on Sep 22, 2010 8:05 AM by leffer1234

    randomizing image/text on refresh

    leffer1234 Level 1

      Hello. I'm new...quite new to DW and web work, but have a small, general understanding of it. I'm an animator and am in the midst of creating my own portfolio site. I don't understand code, at least uber-extreme code. I'm attempting to have specific quotes on my homepage from clients and would like to have them change, or have a new text/quote appear on refresh or upon a new visit to the site (just so it's not the same one everytime).

        Would I need to just render out a .swf file in AE or is there a means of doing this within DW w/o using crazy code? Thanks in advance, Andy

        • 1. Re: randomizing image/text on refresh
          MurraySummers Level 8

          HTML has no way to do something like this.  You would indeed have to use Flash, or JavaScript, or some server-scripting to accomplish that task.

           

          It's quote easy to do with something like PHP, for example, by declaring a random variable in the page, e.g.,

           

          <?php

           

          $imageVar = rand(1,5) /* this will generate a random number between 1 and 5 */

           

          ?>

           

          and then using that random variable in the image's source attribute -

           

          <img src="images/random/image<?php echo $imageVar; ?>.jpg" />

           

          If you are getting the idea that you will have to come to grips with code sooner rather than later, then you are on the right track.  DW is very punishing to those who won't take the time to learn the underlying technologies....

           

          If you Google "random image" and "Dreamweaver" you may also be able to find extensions that do the same thing for you (in JavaScript).  I would recommend that you visit http://www.projectseven.com and search there - I do know that they have such a thing, and can wholeheartedly endorse their products as being the best of show....

          1 person found this helpful
          • 2. Re: randomizing image/text on refresh
            Ken Binney-GnPIX3 Level 4

            Assuming your server supports PHP you can place your images in a folder, rename them as 1.jpg 2.jpg etc

            then insert this tag where you want them to appear.

             

            <img src="images/banners/<?php echo rand(1,6);?>.jpg" alt="Random Image">

            Note change the 6 to the highest number of the images in your folder
            (I used 6 as I had 6 images)

             

            See it in action at http://www.datacarpet.com/

            Each random image is a strip that looks like 4 pictures

            1 person found this helpful
            • 3. Re: randomizing image/text on refresh
              leffer1234 Level 1

              Thanks a ton, guys. I'm going to expand my horizons and attempt some understanding on code. I may be back with questions