Lua Scripting Resources

Important Update to Custom Scripting

SurveyGizmo's CustomScript Action now supports the LUA programming language.


Legacy Custom Scripting Language Deprecation Plans 

  1. New accounts (created after October 29, 2018) will only have the option to use Lua in scripts.
  2. As of October 29, 2018 Custom Scripting Actions will default to Lua as the scripting type in the Custom Scripting Action for accounts created before this date. You will be able to switch to the Legacy Custom Scripting; though we highly encourage using Lua.
  3. In the long term, Legacy Custom Scripting Actions will be switched to read-only. Read-only scripts will continue to function; you will just be prevented from editing. The exact date on this is to be determined; we will send notifications well ahead of time.


 Go to our Legacy Scripting Documentation.

While SurveyGizmo is one of the most flexible survey tools around, we get requests for customizations that are not available out of the box. This is where JavaScript and Custom Scripting can save the day. If you have scripting chops you can use the JavaScript action or the Custom Scripting action to achieve the survey of your dreams.


[article("bodfy")]

Many users like to use our default answers feature to pre-populate their survey. Often they wish to make this field appear as read only so that the respondent cannot change the answer. While this is not a built-in feature, we do have some easy-to-use JavaScript that allows you to make one of the following question types read only.

Compatible Question Types:

Try it out in a survey: 

Check it out in an example survey!

OR

Add a survey with this setup to your account!

The Script and Setup

Once you have your survey set up you will use one of the following scripts below depending on your question type. To add this to your survey click Add New Action > JavaScript

Textbox

This script will disable editing on a textbox with the CSS Class Name rotextbox. Learn how to add a Class Name to your question.

$(document).ready(function(){
  // makes a textbox question with the CSS class name "rotextbox" readonly
  $(":text").attr("disabled",true);
});

Essay

This script will disable editing on a essay with the CSS Class Name roessay. Learn how to add a Class Name to your question.

$(document).ready(function(){
  // makes an essay question with the CSS class name "roessay" readonly
  $(".roessay").find("textarea").attr("disabled",true);
});

Checkbox

This script will disable editing on a checkbox with the CSS Class Name rocheckbox. Learn how to add a Class Name to your question.

$(document).ready(function(){
  // makes a checkbox question with the CSS class name "rocheckbox" readonly
  $(".rocheckbox :checkbox").attr("disabled",true);
});

Radio Button

This script will disable editing on a radio button with the CSS Class Name roradiobutton. Learn how to add a Class Name to your question.

$(document).ready(function(){
  // makes a radio button question with the CSS class name "roradiobutton" readonly  
  $(".roradiobutton :radio").attr("disabled",true);
});

Dropdown Menu

This script will disable editing on a dropdown menu with the CSS Class Name rodropdown. Learn how to add a Class Name to your question.

$(document).ready(function(){
  // makes a dropdown menu question with the CSS class name "rodropdownmenu" readonly
  $(".rodropdownmenu select").attr("disabled",true);
});

If you need to disable all the above question types you can copy this script and make sure to use the appropriate CSS Class Names to disable each question. Learn how to add a Class Name to your question.

$(document).ready(function(){
  // makes a textbox question with the CSS class name "rotextbox" readonly
  $(":text").attr("disabled",true);
  
  // makes an essay question with the CSS class name "roessay" readonly
  $(".roessay").find("textarea").attr("disabled",true);
  
  // makes a checkbox question with the CSS class name "rocheckbox" readonly
  $(".rocheckbox :checkbox").attr("disabled",true);
  
  // makes a radio button question with the CSS class name "roradiobutton" readonly  
  $(".roradiobutton :radio").attr("disabled",true);

  // makes a dropdown menu question with the CSS class name "rodropdownmenu" readonly
  $(".rodropdownmenu select").attr("disabled",true);
});