Hi Joffm,
Thanks for your answer!
You are right, the first script is pretty old (7 years). I got it from the following post from tpartner, where the goal was to set a default value for the dropdown:
www.limesurvey.org/de/foren/can-i-do-thi...er-in-dropdown-array
.
By the "first non-empty value" I am referring to tpartner's post, where he said that "the first option that has a value is selected". I guess the following code snippet corresponds to this:
Code:
$('option[value!=""]:first', this).attr('selected', 'selected');
In my case, I set up an online experiment, in which participants get invited via email containing a unique user id. Based on this user id, I want to set the pre-determined experiment group (and other variables). So what I did was to set up a server under "
www.URL.com
" which has an HTTP endpoint that takes the user id as an argument and sends the experiment group back. The experiment group is a number between 1 and 4. The entire workflow is described as follows:
- Participant receives user id per email
- Participant enters user id in LimeSurvey field
- User id is sent via HTTP request to server and experiment group (and other variables) are returned as a response (this is how I get "obj.experimentGroup")
- The experiment group (and other variables) are saved in hidden fields of the survey
- Based on the experiment group, the participants will see different versions of the survey
I was already able to save the other variables, e.g. the price path, to hidden text fields using this:
Code:
$('#question{30055} input[type="text"]').val([obj.pricePath]);
However, I don't know how to do the corresponding for a dropdown question.
I hope the above clarifies my question.
Thanks a lot