Prefill an array(Text) from a previous array(Text)

More
1 month 14 hours ago #176892 by krosser
krosser created the topic: Prefill an array(Text) from a previous array(Text)
Hi guys,

I have to split a table and present it as two arrays with text inputs. Some answers/text inputs should be identical in both tables. So, I need to prefill certain text inputs in the 2nd array table, when the answers are typed in in the 1st table. I guess that is not possible with the subquestion validation or relevance equation, is it? I couldn't figure out the correct syntax. Would appreciate any help..

For example, "text 1" should appear in the 2nd array as "text 1" and so on...


A test survey attached..

File Attachment:

File Name: limesurvey...5243.lss
File Size:22 KB

I'm using the latest LS 3.15 hosted on LS servers, not installed locally.
Attachments:

Please Log in or Create an account to join the conversation.

More
1 month 14 hours ago #176898 by krosser
krosser replied the topic: Prefill an array(Text) from a previous array(Text)
Okay, guys. I've managed to do it with a JS code. For my particular example it is

<script type="text/javascript">
  $(document).ready(function () {
    $('#answer715243X12X689Y01_X01').on('change', function (e) {
       $('#answer715243X12X698Y01_X01').val($('#answer715243X12X689Y01_X01').val());
     	});
    $('#answer715243X12X689Y02_X01').on('change', function (e) {
       $('#answer715243X12X698Y02_X01').val($('#answer715243X12X689Y02_X01').val());
      	});
    $('#answer715243X12X689Y03_X01').on('change', function (e) {
       $('#answer715243X12X698Y03_X01').val($('#answer715243X12X689Y03_X01').val());
    	});
});
</script>


If someone thinks there is a better way, please let me know :)

I'm using the latest LS 3.15 hosted on LS servers, not installed locally.

Please Log in or Create an account to join the conversation.

More
4 weeks 1 day ago #176938 by DenisChenu
DenisChenu replied the topic: Prefill an array(Text) from a previous array(Text)
The only solution to get it in same page.

You can use {SGQ} then if you copy the survey : don't need updatinf javascript

$(document).ready(function () {
    $('#answer{SGQ}Y01_X01').on('change', function (e) {
       $('#answer{that.Q2.SGQA}Y01_X01').val($(this).val());
     	});
    $('#answer{SGQ}Y02_X01').on('change', function (e) {
       $('#answer{that.Q2.SGQA}Y02_X01').val($(this).val());
      	});
    $('#answer{SGQ}Y03_X01').on('change', function (e) {
       $('#answer{that.Q2.SGQA}Y03_X01').val($(this).val());
    	});
});

Else : you don't really need the Q2 X1 value ? User must not update it ? Right ?

If right : maybe someting like this


Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .
Attachments:

Please Log in or Create an account to join the conversation.

More
4 weeks 1 day ago #176953 by krosser
krosser replied the topic: Prefill an array(Text) from a previous array(Text)
Thanks man, but the script isn't working. I have tried to adjust Y and X there but still, nothing changes...

Regarding your second option, looks cool. I wouldn't be able to figure out the syntax myself. But I'd like to keep the numbers in the 1st subquestion column. It would be great if it was possible to do that for the answer choice column.

I'm using the latest LS 3.15 hosted on LS servers, not installed locally.

Please Log in or Create an account to join the conversation.

More
4 weeks 1 day ago #176967 by DenisChenu
DenisChenu replied the topic: Prefill an array(Text) from a previous array(Text)
No, you need to put the answer on 1st columns … :/

Maybe some javascript solution …

About #answer{SGQ}Y01_X01' : it work if you put the script in question text (or use addScriptToQuestion ).

But you can't use it anywhare else (and maybe i make some error ;))

It use manual.limesurvey.org/Expression_Manager#Access_to_Variables , in question 698 in group 12 in surevy 715243 : {SGQ} must give 715243X12X698

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!