Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Refer to question code to move "other" option

More
5 years 5 months ago #196291 by Jmantysalo
I was asked for a radiobutton element having "other" as the second last option. For one question I was able to do it by adding script
Code:
function moveUp($item) {
     $before = $item.prev();
     $item.insertBefore($before);
}
 
moveUp($('#javatbd177612X75X1738other'));

when I manually look what code the question got. Also I found that {QID} can be used instead of part "1738". But what is the code for all of the "177612X75X1738"-part? I tried {SGQA} and {SGQ} wihtout luck.
The topic has been locked.
More
5 years 5 months ago #196301 by tpartner
This works for me in version 3.22.6:

Code:
<script type="text/javascript" charset="utf-8">
  $(document).on('ready pjax:scriptcomplete',function(){
 
    function moveUp($item) {
      $before = $item.prev();
      $item.insertBefore($before);
    }
 
    moveUp($('#javatbd{SGQ}other'));
    });
</script>

Sample survey attached:

File Attachment:

File Name: limesurvey...4-03.lss
File Size:16.26 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
5 years 5 months ago #196320 by Jmantysalo
Aa-ha! That works also in 4.x. But when I extract the code and put that in the Script-field (below the Help-field), then it does not. So {SGQ} can not be used everywhere. Thanks.
The topic has been locked.
More
5 years 5 months ago #196327 by DenisChenu

Jmantysalo wrote: So {SGQ} can not be used everywhere.

I think it's an issue and must be reported ...

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
The topic has been locked.
More
5 years 5 months ago - 5 years 5 months ago #196328 by DenisChenu
Else : you can use
Code:
{QCODE.s gq a}
(no space inside sgqa ...) anywhere :)
www.limesurvey.org/manual/Expression_Man...#Access_to_Variables

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
Last edit: 5 years 5 months ago by DenisChenu.
The topic has been locked.
More
5 years 5 months ago #196336 by Jmantysalo
I do not undestand. Putting just alert({QID}); to script field of a question gives an alert, but nothing like {QCODE}, {Qcode.sgqa} etc. do not work. Can you make an example survey?
The topic has been locked.
More
5 years 5 months ago #196351 by DenisChenu
I try to make a sample survey but don't seems to work for me
16090: No javascript mantis issue


You can try

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
The topic has been locked.
More
5 years 5 months ago - 5 years 5 months ago #196355 by tpartner
When is that JS loaded?

Maybe it should be wrapped in

Code:
$(document).ready(function() {...});

or

Code:
$(function() { ... });

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 5 years 5 months ago by tpartner.
The topic has been locked.
More
5 years 5 months ago #196361 by Jmantysalo
There reads "This optional script field will be wrapped, so that the script is correctly executed after the question is on the screen.", so there should be no need to manually write a wrapper.
The following user(s) said Thank You: DenisChenu
The topic has been locked.
More
5 years 5 months ago #196392 by DenisChenu
+1 for @Jmantysalo

@tpartner : even with wrapper : "i just want to log something" are not in source code :)

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose