- Posts: 222
- Thank you received: 10
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Prefill an array(Text) from a previous array(Text)
- krosser
- Topic Author
- Offline
- Elite Member
Less
More
5 years 5 months ago #176892
by krosser
I'm using the latest LS 3.22 hosted on LS servers, not installed locally.
Prefill an array(Text) from a previous array(Text) was created by krosser
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..
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..
I'm using the latest LS 3.22 hosted on LS servers, not installed locally.
Attachments:
The topic has been locked.
- krosser
- Topic Author
- Offline
- Elite Member
Less
More
- Posts: 222
- Thank you received: 10
5 years 5 months ago #176898
by krosser
I'm using the latest LS 3.22 hosted on LS servers, not installed locally.
Replied by krosser on 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
If someone thinks there is a better way, please let me know
Code:
<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.22 hosted on LS servers, not installed locally.
The topic has been locked.
- DenisChenu
- Away
- LimeSurvey Community Team
Less
More
- Posts: 13642
- Thank you received: 2491
5 years 5 months ago #176938
by DenisChenu
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 .
I don't answer to private message.
Replied by DenisChenu on 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
Else : you don't really need the Q2 X1 value ? User must not update it ? Right ?
If right : maybe someting like this
You can use {SGQ} then if you copy the survey : don't need updatinf javascript
Code:
$(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 , plugin development .
I don't answer to private message.
Attachments:
The topic has been locked.
- krosser
- Topic Author
- Offline
- Elite Member
Less
More
- Posts: 222
- Thank you received: 10
5 years 5 months ago #176953
by krosser
I'm using the latest LS 3.22 hosted on LS servers, not installed locally.
Replied by krosser on 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.
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.22 hosted on LS servers, not installed locally.
The topic has been locked.
- DenisChenu
- Away
- LimeSurvey Community Team
Less
More
- Posts: 13642
- Thank you received: 2491
5 years 5 months ago #176967
by DenisChenu
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 .
I don't answer to private message.
Replied by DenisChenu on 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
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 , plugin development .
I don't answer to private message.
The topic has been locked.