1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Random Image Code Help

Discussion in 'Web Design & Development' started by The Infinity, Feb 1, 2007.

Thread Status:
Not open for further replies.
Advertisement
  1. The Infinity

    The Infinity Thread Starter

    Joined:
    May 11, 2005
    Messages:
    579
    I would like to use an random image code on my website like this one:

    http://www.java-scripts.net/javascripts/Random-Image-Script.phtml

    The only problem is I want a caption to be under the image such as "Turtleman's Image" and when it changes to another image have it display different text for the other image such as "Turtleman's Brother's Image".

    Sorry for the weird example but I think that gets the point across.
     
  2. namenotfound

    namenotfound

    Joined:
    Apr 30, 2005
    Messages:
    3,012
    Ok I know very little JavaScript, but just looking at the code, I'm going to take an educated guess. This may or may not work. My edits will be in bold:


     
  3. The Infinity

    The Infinity Thread Starter

    Joined:
    May 11, 2005
    Messages:
    579
    The only thing is I need a code that will work within DIV tags.

    And so far I can't get the code above to work :(
     
  4. The Infinity

    The Infinity Thread Starter

    Joined:
    May 11, 2005
    Messages:
    579
    Well I tried looking up more scripts but none of them I could find would even work within DIV tags.
     
  5. namenotfound

    namenotfound

    Joined:
    Apr 30, 2005
    Messages:
    3,012
    Couldn't you just do


    <div>
    <script>
    ...
    </script>
    </div>

    and just wrap that javascript in div tags?
     
  6. The Infinity

    The Infinity Thread Starter

    Joined:
    May 11, 2005
    Messages:
    579
    technically yes but according to W3C validation its not valid.
     
  7. namenotfound

    namenotfound

    Joined:
    Apr 30, 2005
    Messages:
    3,012
    Change <script language="JavaScript"> to <script type="text/javascript"> that should then validate.

    <div>
    <script type="text/javascript">
    ......
    </script>
    </div>

    It validated when I tried.
     
  8. The Infinity

    The Infinity Thread Starter

    Joined:
    May 11, 2005
    Messages:
    579
    Still doesn't work :(

    It just won't display within the DIV tags.
     
  9. knight_47

    knight_47

    Joined:
    Mar 14, 2006
    Messages:
    941
    Why don't you use a PHP script then? If you can, let me know.
     
  10. The Infinity

    The Infinity Thread Starter

    Joined:
    May 11, 2005
    Messages:
    579
    Actually I got it. I ended up having to tweak the script a lot to get it to recognize everything but it worked.

    And the script tags did finally end up working inside the div tags :)
     
  11. namenotfound

    namenotfound

    Joined:
    Apr 30, 2005
    Messages:
    3,012
    Glad you got it working :)
     
  12. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/540356