Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 657 Vote(s) - 3.46 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Masking answer options in Confirmit (jscript)

#1
I'm trying to mask the answer options that show up in a 3DGrid question item in Confirmit, using the value of a background variable.

E.g. when "background1" ==1, display answer category 1. If "background1" ==0, do not display answer category 1. If "background2" ==1, display category 3, otherwise do not. In any case, display answer category 2.

Hopefully this is easy for someone out there (I'm a psychologist, not a coder...so not so much so for me :/)

Thanks!
Reply

#2
In order to access the data inside a question/variable we can use the f function of confirmit.

for instance:

f('my_question_id').get();

When masking a question, we need to pass in a Set object so Confirmit knows what `Code`'s to show and not to show.

Often you will mask using a Set from a previous question. So you pass in the question_id and Confirmit does all the other magic.

Here we have the problem of not having a Set, so we will have to create our own.

For this, there are 2 approaches (can be found in the scripting manual under `Working with Sets > Methods of the set Object > add and remove` and `Working with Sets > User defined functions...`)

I'm going to stick to the first one because it is easier to use ;)
What we will do first is create a script node (it doesn't matter where you create it, just somewhere in the survey, I often have a folder Functions with all my script nodes in somewhere at the bottom of my survey)

In that script file we will have our function that crates our set:

function CreateMyAwesomeSet()
{
//create an empty Set
var mySet = new Set();

//if background1 equals 1, add 1 to our Set
if ( f('background1').get() == '1' )
{
mySet.add(1);
}

//return the Set of allowed Codes
return mySet;
}

Here we declare a function that we now can use wherever we want to.

So now, If we want to use this Set, we add a Code Mask to your grid:

CreateMyAwesomeSet()

You can ofcourse change the name of the function, and add extra if statements.

hope this helps
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through