CfMC JavaScripts
for Web-based research
With webSurvent and webCATI, you can use JavaScripts to make individual pages more dynamic and control for quality within a page before that page is submitted to the server. You can also use JavaScripts to enhance the usability of the survey for the research participant.
Several JavaScripts are included with webSurvent 7.7 (some are included in v7.6) install, although none are required by the software. Each install includes several Java Scripts which enable capabilities like:
- passing data through a survey URL (username and password, market/segment, etc)
- checking responses and/or creating dynamic skip patterns as respondents answer questions on a survey page (12 dynamic data checking scripts available)
- using a status bar
- sending respondents to a specific URL upon completion of the survey
- disabling a respondent’s ability to right click in a survey ;
- and much more!
JS downloads
Updates for these scripts are available by contacting support. You may also find more detailed descriptions and instructions on how to use these JavaScripts in the webSurvent/webCATI and Survent technical manuals.
webSurvent / webCATI version 7.7
Initial77.js - for passing data and managing cookies
This script allows you to pass data via a URL string into the survey – such as a password and username or sample selection data. This way, you can drive some respondents from one segment to one survey and another segment to another version of the survey.
This script also auto submits the page and manages cookies for limiting access on open studies.
cfmc_ws77.js - data control before submit
This JavaScript is a master script that contains 12 dynamic data-checking (before "submit") scripts:
- findother function – dynamically forces the other specify always to be entered if other is chosen or use a “pop-up” other
- setcount function - create a link between a series of numeric questions to show a running total as the numbers are entered into the page and, if set, force the total to equal a specific target.
- setdep function - create onscreen skip patterns so that designated questions cannot be answered if a question on the same page does not have the proper response.
- setnoskip function - force a response to some questions on a screen while allowing others to remain blank.
- setnum function - check numeric entries for the correct range and number of decimals.
- setorder function - record the order of mention of responses in a multi-response question. Selecting an “exception” code will clear the other responses
- setrank function - Check a series of ranking questions to make sure the same rank cannot be given and allows you to specify a number of items to be ranked.
- settab function - To create a specific tab order onscreen so that if the respondent hits the tab key, they move through the page in a specific order.
- setunique function - Designate a given response on a multiple-response question as a unique response and prevent a respondent from giving another answer the same response.
- textlen function - Give a warning when the maximum text allowed is approached for a question.
- textex function - Associate a text question with a categorical question so that you can only answer one or the other.
- setna function - Create a one-to-many relationship between questions so that if one is answered, then the others cannot be selected.
user_settings.js - improve the user experience
The user_settings JavaScript provides useful tools to control and improve how a respondent participates in your Web survey. Feel free to make these scripts your own by altering the messages and settings contained in the scripts.
Functions in this script include:
- parse_query function – enables the survey to read data that is passed from the index page into the first page of the survey and store it in hidden var,h questions.
- no_right click function – prevents right-clicking the mouse while in a survey stopping respondents from accessing menu options that would otherwise be unavailable when running in a pop-up window and prevents the use of browser forward and browser backward by always loading the last page in the browser’s history.
- statbar function - this function creates an image-driven status bar onscreen, showing the respondent a graphic representation of how much of the survey has been completed and how much remains to be done.
- suspend template functions - dynamically determines the URL for the study and displays that to the screen when a respondent suspends a survey. It closes the screen after a defined number of seconds when using a pop-up window and allows you to route the respondent to a new URL after suspending. It also allows you to create a bookmark button for easy re-entry into the survey and automatically creates a link that will take a respondent back into the survey if they suspend by mistake.
- complete template function - closes the pop-up window after a specified amount of time sends the respondent to a different URL after completing.
- terminate template function – closes the pop-up window after a specified amount of time and sends the respondent to a different URL after terminating.
Imgv1_0.js - for image use
CfMC Web-based data collection tools empower you to present images to your preferences. These functions are included in this script:
- changeimg - provides a simple way to change which image is shown (i.e. the source of an image) based on the survey response
- setimg1 - presents an image on the page for a specified amount of time.
- popimg - provides a way to present images in a pop-up window.
- showseries - provides a way to present a series of images either sequentially or randomly.
JavaScripts available in version 7.6
The CfMC JavaScripts provided in v7.7 were a vast improvement on previous versions. Here's a summary of the differences:
- initial.js - data passing is not available in v7.6
- cfmc_ws76.js - the scripts used for the template files are not available. These scripts were improved in v7.7 - so was setup.
- user_settings.js was not available for v7.6, so messages were less customizable.
JavaScript updates
Regular updates to these scripts and their documentation are available by sending an e-mail to getfiles@cfmc.com with the subject “show files”. You can check which version of the scripts you have by looking at the comments at the top of each script. If you run into problems using these scripts or have a need for a script that is not included, please contact support .

