Refer to question code to move "other" option

More
1 month 3 weeks 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
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.

Please Log in to join the conversation.

LimeSurvey Partners
More
1 month 3 weeks ago #196301 by tpartner
This works for me in version 3.22.6:

<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 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Official LimeSurvey Partner - partnersurveys.com
Attachments:

Please Log in to join the conversation.

More
1 month 3 weeks 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.

Please Log in to join the conversation.

More
1 month 3 weeks 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 service on demand , plugin development .
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

More
1 month 3 weeks ago - 1 month 3 weeks ago #196328 by DenisChenu
Else : you can use
{QCODE.s gq a}
(no space inside sgqa ...) anywhere :)
manual.limesurvey.org/Expression_Manager#Access_to_Variables

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
An error happen ? Before make a new topic : remind the Debug mode .
Last edit: 1 month 3 weeks ago by DenisChenu.

Please Log in to join the conversation.

More
1 month 3 weeks 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?

Please Log in to join the conversation.

More
1 month 3 weeks 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 service on demand , plugin development .
An error happen ? Before make a new topic : remind the Debug mode .
Attachments:

Please Log in to join the conversation.

More
1 month 3 weeks ago - 1 month 3 weeks ago #196355 by tpartner
When is that JS loaded?

Maybe it should be wrapped in

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

or

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

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Official LimeSurvey Partner - partnersurveys.com
Last edit: 1 month 3 weeks ago by tpartner.

Please Log in to join the conversation.

More
1 month 3 weeks 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

Please Log in to join the conversation.

More
1 month 3 weeks 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 service on demand , plugin development .
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now