0

My institution recently upgared to Limesurvey 3.

I used to prefill a radio question containing an "Other" answer, using this js code :

<script>   
$(document).ready(function() {

    $("#question{CODE.qid} input:radio[id$='other']").trigger('click');    

});  </script>

I think that code worked with Limesurvey 2 (I am not sure anymore and I cannot test it).

I managed to solve my issue in Limesurvey 3 with this code :

<script>   
$(document).ready(function() {

    $("#question{CODE.qid} input:radio:last").trigger('click');    

});  </script>

But my question is : In Limesurvey 3, is there a way to prefill answer with the former method, eg using something like id$='other'?

EDIT: I need a jquery solution, which is used by Limesurvey.

Additionnaly, I would like to prefill (with an attribute) the text related to the "Other" answer.

Is it possible to do that ?

stephLH
  • 131
  • 7
  • Possible duplicate of [How to select a radio button by default?](https://stackoverflow.com/questions/5592345/how-to-select-a-radio-button-by-default) – jmargolisvt Oct 05 '18 at 19:32
  • The given answers in your link are not related with jquery, which is used by Limesurvey. – stephLH Oct 05 '18 at 19:40

1 Answers1

1

Why use jquery/javascript when you can use tool dedicated system …

Add an hidden equation before you question, hide it and put inside

{CODE=if(is_empty(CODE.NAOK),"-oth-",CODE.NAOK)} {CODE_other=if(is_empty(CODE.NAOK),TOKEN:ATTRIBUTE_1,CODE_other.NAOK)}

This fix the 2 feature you need, see https://manual.limesurvey.org/Expression_Manager#Using_Assignment_Operator for reference.

Denis Chenu
  • 846
  • 2
  • 7
  • 22
  • Thank you Denis. Now I understand EM (after almost 2 years using LM...). on the other hand, the code "-oth-" was not trivial, I could not find it in the documentation. – stephLH Oct 07 '18 at 19:33