Empirisoft Support

    Welcome to Empirisoft Support
Results 1 to 2 of 2

Thread: Choosing a file at random

  1. #1
    Join Date
    Feb 2008
    Posts
    2

    Choosing a file at random

    In my study, I'm having the participants give a scale rating of four different fictional people ("Rate how you feel about Rachel from a scale of 1-7") and I'd like all four of the people to be on the same screen (so it looks like a multiple-choice test one one screen). I also need the four people to be listed in random order so we don't get order effects when the subjects rate each person. What is the best way to do this? My study is in MediaLab and I found that I could only have them all on the same page by using html, but how can I get the four people to be randomized within that page? Make all the possible orders, 16 files, and somehow have the program randomly pull out one of them?

    Thanks so much!

  2. #2
    Join Date
    Nov 2005
    Posts
    3,328
    Found this at:

    http://www.experts-exchange.com/Prog..._22928024.html


    I have table on a web page that is displaying 7 different images, what I need to do is to somehow randomize the position of where each image is displayed within the table each time the page loads so that there is not one preference.

    I need the 7 images to appear on the page at all times, I've had a scout around the web for a script but haven't found one that displays the 7 seven images each time.

    this should work:
    Code:
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Randomize Images Location</title>
    <style type="text/css">
    <!--
    .style1 {
          font-family: Verdana, Arial, Helvetica, sans-serif;
          font-size: 12px;
          font-weight: bold;
    }
    -->
    </style>
    <script type="text/javascript">
    var imgs = new Array();
    imgs.push("Image1.jpg");
    imgs.push("Image2.jpg");
    imgs.push("Image3.jpg");
    imgs.push("Image4.jpg");
    imgs.push("Image5.jpg");
    imgs.push("Image6.jpg");
    imgs.push("Image7.jpg");
     
    function rndmImg(root)
    {
          var tmpArry = imgs.concat();
          var pics = root.getElementsByTagName("img");
          var len = imgs.length;
          for(var i=0; i<len; i++)
          {
                var rnd = Math.floor(Math.random()*tmpArry.length);
                pics.src = tmpArry.splice(rnd,1);
         }
    }
    </script>
    </head>
     
    <body onload="rndmImg(document.getElementsByTagName('table')[0]);">
    Randomize Images Location
     
    <table width="600" border="1">
     <tr>
       <th scope="col"><img width="120" height="92" border="0" /></th>
       <th scope="col"><img width="120" height="92" border="0" /></th>
       <th scope="col"><img width="120" height="92" border="0" /></th>
       <th scope="col"><img width="120" height="92" border="0" /></th>
       <th scope="col"><img width="120" height="92" border="0" /></th>
       <th scope="col"><img width="120" height="92" border="0" /></th>
       <th scope="col"><img src="Image7.jpg" width="120" height="92" /></th>
     </tr>
    </table>
    &nbsp; 
     
    </body>
     
    </html> 
    Excellent thanks basicinstinct works a charm.
    Haven't tried it but maybe it's a start. If you get it working it would be great if you could zip and post a sample!
    Last edited by jarvis24; 09-17-2010 at 03:01 PM.

Similar Threads

  1. Order of random questions in data file
    By jarvis24 in forum DirectRT Older Versions: Troubleshooting
    Replies: 5
    Last Post: 06-24-2009, 03:45 AM
  2. Random presentation times?
    By jarvis24 in forum DirectRT Older Versions: General Questions
    Replies: 3
    Last Post: 09-24-2008, 05:07 PM
  3. Random Distribution
    By jasonp220 in forum MediaLab Older Versions: General Questions
    Replies: 3
    Last Post: 03-25-2008, 10:19 AM
  4. How do I record random trial order in output file?
    By mugur65 in forum DirectRT Older Versions: Troubleshooting
    Replies: 3
    Last Post: 10-19-2007, 12:55 PM
  5. Choosing a Joystick
    By JEC in forum Hardware: How Do I...
    Replies: 0
    Last Post: 07-18-2006, 04:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •