Can I pre-fill survey questions so that some questions already have values when the survey initially loads?

Yes, his can be done two different ways as seen below. This only works for the first page if it is a multi-page survey.

NOTE: These two methods are likely to be only used for public survey links as opposed to using the Participants List. This is because there is not a real opportunity to modify the survey links sent to participants via the Participants List because REDCap automatically sends them out as-is.

1) Append values to the survey link: The first method is for pre-filling survey questions by appending URL parameters to a survey link. The format for adding URL parameters is to add an ampersand (&) to the end of the survey link, followed by the REDCap variable name you wish to pre-fill, followed by an equals sign (=), then followed by the value you wish to pre-fill in that question.

For example, if the survey URL is https://redcap.vanderbilt.edu/surveys/?s=dA78HM

then the URL below would pre-fill "Jon" for the first name question, "Doe" for last name, set the multiple choice field named "gender" to "Male" (whose raw/coded value is "1"), and it would check off options 2 and 3 for the "race" checkbox.

https://redcap.vanderbilt.edu/surveys/?s=dA78HM&first_name=Jon&last_name=Doe&gender=1&race___2=1&race___3=1 

WARNING: This method is not considered secure for transmitting confidential or identifying information (e.g. SSN, name), even when using over SSL/HTTPS. If you wish to pre-fill such information, it is highly recommended to use method 2 below.


2) Submit an HTML form to a REDCap survey from another webpage: The second method is for pre-filling survey questions by posting the values from another webpage using an HTML form. This webpage can be *any* webpage on *any* server. See the example below. The form's "method" must be "post" and its "action" must be the survey link URL. The form's submit button must have the name "__prefill" (its value does not matter). Each question you wish to pre-fill will be represented as a field in the form, in which the field's "name" attribute is the REDCap variable name and its value is the question value you wish to pre-fill on the survey page. The form field may be an input, text area, or select field. (The example below shows them all as hidden input fields, which could presumably have been loaded dynamically, and thus do not need to display their value.) If submitted, the form below would pre-fill "Jon" for the first name question, "Doe" for last name, set the multiple choice field named "gender" to "Male" (whose raw/coded value is "1"), and it would check off options 2 and 3 for the "race" checkbox. In this example, the only thing that would be seen on the webpage is the "Pre-fill Survey" button.

<!-- Other webpage content goes here --> <form method="post" action="https://redcap.vanderbilt.edu/surveys/?s=dA78HM"> <inp
  • No labels