How to Conduct Behavioral Research over the Internet: A Beginner's Guide to HTML and CGI/Perl

Internet resource for the book by R. Chris Fraley, published by Guilford Press

Chapter overviews and demonstrations
Learn more about the topics covered by the book and see live demonstrations of the exercises

Downloads
Download the HTML, CGI/Perl, and image files used in the book

FAQ
Read answers to frequently asked questions about conducting research online

Discussion forum
Share ideas, scripts, and questions with others on the online forum

Order the book
Order a copy of the book

Resources and links
Links to programs that may be of interest to online researchers

Home page
Overview of the book

 

 

  
Overview of the chapters and live demonstrations of examples from the chapters
Learn more about the topics covered by the book and see live demonstrations of the exercises

Chapter 1
Introduction


This chapter introduces the reader to the objectives and scope of the book. I outline what the reader will be able to accomplish by reading this book and by working through the examples. This chapter also explains prerequisites for using the book (i.e., a personal computer and an Internet connection), and summarizes some useful terminology and concepts.

[PDF sample chapter]
[On-line quiz for chapter 1]


Chapter 2
Getting Started: A Step-by-Step Guide to Using a Web Server


In this chapter I discuss two ways to obtain access to a web server. The first approach involves using a professional web hosting service. The second alternative involves turning a standard PC into a web server. By the end of the chapter, the reader should have his or her own web server.

[On-line quiz for chapter 2]


Chapter 3
HTML Basics: How to Make a Web Page from Scratch


In this chapter I explain how to create a web page in hypertext markup language (HTML). I highlight some useful HTML codes for adjusting the appearance of text (e.g., bold face, font size), inserting images and links into web pages, and creating tables for organizing the placement of text and images. By the end of this chapter, the reader should be able to create a basic web page that can be viewed by anyone using the Internet.


[On-line quiz for chapter 3]

Live Demonstrations
These four pages simply illustrate the way some basic HTML codes appear in your browser window.

example1.htm
Simple example of how text is displayed using HTML code.

example2.htm
Setting the title of the web page
.

example3.htm

An example of how various HTML tags (e.g., <B>, <I>) are rendered on a web page.


home.htm

An example of a "home page" that uses a variety of HTML techniques covered by Chapter 3.


Chapter 4
HTML Forms: Collecting Research Data from Participants via the Internet


The objective of this chapter is to discuss HTML forms--ways of obtaining input from users over the Internet. I discuss several HTML input devices that are commonly used in web research: text boxes, radio buttons, checkboxes, and pull-down menus. By the end of this chapter, the reader should be able to create a basic web page that a research participant can use to input responses.


[On-line quiz for chapter 4]

Live Demonstrations

examplesurvey1.htm
This page demonstrates several ways (e.g., checkboxes, selection menus, and radio buttons) of collecting information from users on-line.


examplesurvey2.htm
This page illustrates the use of image maps. When the image is clicked, the x, y coordinates of the clicked spot are sent to the researcher.


moodsurvey.htm

This page illustrates the use of HTML tables to format the presentation of survey items.


Chapter 5
An Introduction to CGI Scripting: Using Perl to Automatically Save Response Data to a File


This chapter provides an introduction to CGI programming in Perl. CGI scripts are programs that run on the web server that can be used to process a participant's data. To illustrate how to write CGI scripts, I walk the user through a program designed to save response data from an online questionnaire to a text file on the server. I also illustrate how text files can be imported into popular statistical packages, such as SPSS, for data analysis.

Live Demonstrations

moodsurvey2.htm
This page uses the same mood survey discussed in Chapter 4, but the submitted data are automatically processed and saved by the server.


Chapter 6
Providing Customized Feedback to Research Participants


One of the advantages of conducting psychological research online is that it is possible to provide your participants with immediate feedback about their scores. Moreover, it is possible to program a CGI script to analyze the data on-the-fly and summarize the results for your participants as part of the debriefing process. To illustrate these features, I walk the reader through an example of an online questionnaire designed to measure self-esteem. After the user submits his or her responses, the CGI script computes the user's self-esteem score, and reports the average self-esteem score for everyone who has taken the survey.

Live Demonstrations

self-esteem.htm
This page uses a simple self-esteem scale in order to illustrate the way in which responses can be processed by the server in order to provide the user with feedback.

self-esteem2.htm
This page uses a simple self-esteem scale in order to illustrate the way in which responses can be processed by the server in order to provide the user with feedback. The CGI script that processes the data provides feedback to the user regarding his or her self-esteem score.

self-esteem3.htm
This page uses a simple self-esteem scale in order to illustrate the way in which responses can be processed by the server in order to provide the user with feedback. The CGI script that processes the data provides feedback to the user regarding his or her self-esteem score. It also analyzes the data from the larger sample and provides the average self-esteem score for participants.

self-esteem4.htm
This page uses a simple self-esteem scale in order to illustrate the way in which responses can be processed by the server in order to provide the user with feedback. he CGI script that processes the data provides feedback to the user regarding his or her self-esteem score. It also analyzes the data from the larger sample and provides the average self-esteem score for participants, along with feedback on whether the user is above or below the mean.


Chapter 7
Randomizing the Order of Stimuli

In many research contexts it is necessary to randomize the order in which stimuli are presented. In this chapter, I explain how to implement randomization in CGI scripts. As an example, I build on the self-esteem questionnaire introduced in Chapter 6, showing how the order in which the items are presented can be randomized without losing the ability to process or store the data in an organized manner.

Live Demonstrations

randesteem1.pl
This page illustrates the use of randomization processes in Perl to present the self-esteem items discussed in Chapter 6 in a random order for each user. Despite the random presentation order, the data are appropriately processed and saved by the server.

fornextexample1.pl
This page illustrates the way in which for-next loops operate in Perl.

fornextexample2.pl
This page illustrates the way in which index values can be used within a loop to designate elements of a variable array.

randexample.pl
This page illustrates the use of randomization processes in Perl to present image-based stimuli for each user.

randesteem2.pl
Like randesteem.pl, this page uses randomization to present self-esteem items. However, this page randomly samples 5 items from a larger pool of 10 items.


Chapter 8
Random Assignment of Participants to Conditions


Building on the randomization techniques discussed in Chapter 7, in this chapter I explain how to randomly assign participants to different conditions of an online experiment.

Live Demonstrations

randassign.pl
This page randomly assigns users to one of two conditions (by redirecting them to one of two web pages) as a demonstration of random assingment to conditions in Perl. Despite random assignment, the data are appropriately processed and saved by the server.

randassign2.pl
This page randomly
assigns users to one of two conditions as a demonstration of random assingment to conditions in Perl. Unlike the previous script, this one does not redirect the user to a separate webpage. Instead, this one script is responsible for the random assignment and for presenting the stimuli. Despite random assignment, the data are appropriately processed and saved by the server.


Chapter 9
Using Multiple Web Pages in Research: Carrying Responses Forward from One Page to the Next


There are many research situations in which it is necessary to present stimuli or sets of stimuli on separate web pages. However, because the relationship between a web server and a web user is stateless (i.e., there is no natural "memory" for the interaction once a single transaction is complete), various "tricks" need to be employed to carry response data from one page to the next across a single research session. This chapter discusses the use of hidden tags as a way to pass data from one page to the next. Several examples are provided that help to illustrate the effective use of this technique.

Live Demonstrations

multiform1.pl
This page illustrates a method for presenting a separate item/stimulus per page. The program uses "hidden tags" in order to pass the responses from one page to the next. This transmission of information takes place beneath the surface and does not interfere with the user's experience.

randmultiform1.pl
This page is a more complex version of multiform.pl. Again, each item is presented on a separate page. However, the order in which the items is presented is randomized. Despite the random presentation order and the use of separate pages, the data are appropriately processed and saved by the server.

randmultiform3.pl
This example is similar to the previous, except that it employs an image map as a submit button. As a consequence, the user can click once along a continuous scale both to record his or her response and to advance to the next question.


Chapter 10
Using Conditional Branching Structures: An Example of "Skip Patterns" in Survey Research


There are many situations in which it is useful to make the delivery of stimuli contingent upon the user's responses to previously presented stimuli. In this chapter I explain how to create conditional branching structures in a CGI program. To illustrate these techniques, I draw on an example using "skip patterns" in survey research in which certain questions are presented to the participant (e.g., "How many children do you have?") only if the participant has responded in specific ways to previous questions (e.g., "Do you have children?").

Live Demonstrations

skippatterns.pl
This page illustrates the way skip patterns can be implemented by Perl. The questions the user receives depend on his or her answers to previous questions.


Chapter 11
Advanced Feedback: Summarizing Data with Bar Graphs and Two-Dimensional Plots


Participants often find it rewarding to see the results of the study summarized graphically. In this chapter I explain techniques for summarizing research results on-the-fly using bar graphs and two-dimensional coordinate plots.

Live Demonstrations

graphdemobar.pl
This page is an interface to illustrate the graphbar.pl program. graphbar.pl takes the means for a 2 X 2 experiment entered on this page and plots them as a bar graph.

graphdemo2d.pl
This page is an interface to illustrate the graph2d.pl program. graph2d.pl takes a person's scores on two variables and plots the individual's location in two-dimensional space.

graphdemo2dsimple.pl
This page is an interface to illustrate the graph2dsimple.pl program. graph2dsimple.pl takes a person's scores on two variables and plots the individual's location in two-dimensional space, without using image files.


Chapter 12
Tracking Participants over Multiple Sessions: PINs, Passwords, and Menus


Some research situations may require participation on the part of the subject over multiple sessions. In this chapter I explain how to implement personal identification numbers (PINs) and passwords to track a subject's data over time.

Live Demonstrations

pindemo1.pl
This page illustrates a general method for implementing logins and passwords. In addition, this page illustrates a method that allows the same user to complete different questionnaires for the same study at different times. This can be used for time-intensive studies, or for longitudinal research.


Chapter 13
Measuring Response Times


Many psychologists measure response times as a way to make inferences about psychological processes. In this chapter I discuss the contexts in which response times can and cannot be measured effectively over the internet. Several examples are provided to illustrate ways to assess response times online.

Live Demonstrations

rtdemo1.pl
This page illustrates a basic method for assessing reaction times on-line. This particular program does not involve randomization, nor does it analyze the data from the sample at large.

rtdemo2.pl
This page builds on rtdemo1.pl by analyzing the data from the sample at large as part of the feedback page.

rtdemorand1.pl
This page builds on rtdemo2.pl by randomizing the order of the stimuli. Despite randomization, the method enables the reaction times to be computed and saved appropriately.


Chapter 14
Additional Applications of Perl: Discussion Forums and Scored Tests


Many of the techniques discussed in this book can be applied to teaching contexts. Because many research psychologists also teach, I illustrate explicitly how CGI programs can be used to enhance one's teaching experience. Specifically, I explain how to create an online discussion forum (i.e., a web page on which users can post and discuss questions and ideas). I also explain how to create online multiple-choice quizzes that are automatically graded by the server and automatically track which students have taken the quiz and their respective scores.

Live Demonstrations

forumdiscussion.pl
This page illustrates the construction and use of internet forums. forumdiscussion.pl is the main page, but each of the other "forum" scripts is activated at different stages of forum use.

onlinequiz.pl
This page illustrates the way Perl can be used to create on-line quizes that (a) randomly select items from a larger data bank, (b) randomize the order of the items presented, (c) automatically grades the quiz and provies feedback, and (d) save the respones.


Chapter 15
Wrapping it Up


The purpose of this chapter is to discuss a variety of miscellaneous, but important, topics concerning Internet research. These topics include ethical concerns, server maintenance, security, sampling issues, participant drop out, data quality control, and web design.


R. Chris Fraley | http://www.psych.uiuc.edu/~rcfraley/