Javascript random images?

Discussion in 'Software' started by Chris1979, Mar 12, 2007.

  1. Chris1979

    Chris1979 Private E-2

    I want to make a script that will display 4 random images at a time, with none of the being the same ie:
    :cool :p :cry :(
    not:
    :p :cool :cry :cool

    I have looked all over and found guides for making 1 image show and be random but not more that 1 :(

    at the moment im using a 4 pic imagemap so people can click on the images and get a larger view.

    what im aiming for is to have these 4 pictures be randomly chosen from X, not repeat in the same instance and be clickable to show larger/full image.

    I could just make x number of 4 pic imagemaps and then randomise these, but this sucks and there must be a cleaner / eaiser way.
     
  2. Kodo

    Kodo SNATCHSQUATCH

    use an array and place the paths to the possible images in them.

    then get 4 random numbers
    then use the DOM to insert 4 new images into the page at the desired node.
    make your life easy and use a JavaScript library like "X", "Prototype" or Scriptaculous.. heck even the MS Ajax library will be helpful.
     
  3. Chris1979

    Chris1979 Private E-2

    Thanks for your suggestions Kodo I'll make good use of them :)
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds