Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

wordmunger

macrumors 603
Original poster
Sep 3, 2003
5,124
3
North Carolina
Quick question for those more computer-savvy than I am. Can you help me divide readers into five roughly equal groups (it's for this week's Casual Friday on Cognitive Daily) within Survey Monkey, an online survey site.

In the past, I've relied on the "what month is your birthday in" question, but it won't work when I need five groups.

Surely there's a simple javascript out there that would automatically return a random number from 1 to 5. Then I can just ask people what number they see, and then direct respondents to the correct survey based on the number.

I've done a few searches, but most of the scripts I could find have been too complicated, requiring user input. I just want the number to be automatically generated according to my specifications.

Thanks in advance for your help!
 

wordmunger

macrumors 603
Original poster
Sep 3, 2003
5,124
3
North Carolina
Just as an FYI, a cogdaily reader showed me how to do it:

Code:
<p>
Presenting a number between 1 and 5:
<script language="javascript">
function random( numGroups )
{
var num = Math.round( numGroups * Math.random() );

return num == 0 ? numGroups : num;
}

document.write( random( 5 ) );
</script>
</p>
 

iSee

macrumors 68040
Oct 25, 2004
3,540
272
Why not pick a random survey automatically? That way, the user doesn't have to enter anything.

Or is it to prevent 'bots from getting to your survey, or something like that?
 

wordmunger

macrumors 603
Original poster
Sep 3, 2003
5,124
3
North Carolina
Why not pick a random survey automatically? That way, the user doesn't have to enter anything.

Or is it to prevent 'bots from getting to your survey, or something like that?

Because I want their survey results to appear together in the same survey, and survey monkey doesn't support that sort of automation from within. I could randomize it automatically on entering the survey, but then I'd have to analyze five different results files.

For example, two weeks ago we did a survey which divided participants into four groups; some of them saw one version of a movie, and others saw a different version. Then all respondents were asked the same questions about the movie.

If you'd like to try the new survey, complete with randomization script, here's the link:

PowerPoint survey

The survey is designed to determine whether we learn better from PowerPoint (actually Keynote!) or plain text.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.