- Posts: 174
- Thank you received: 9
- Forum
- English support forums
- Can I do this with LimeSurvey?
- Prefill an array(Text) from a previous array(Text)
Prefill an array(Text) from a previous array(Text)
3 months 5 days ago #176892
by krosser
I'm using the latest LS 3.15 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.15 hosted on LS servers, not installed locally.
Please Log in or Create an account to join the conversation.
3 months 5 days ago #176898
by krosser
I'm using the latest LS 3.15 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
<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.
- DenisChenu
-
- Away
- LimeSurvey Community Team
-
Less
More
- Posts: 10512
- Karma: 408
- Thank you received: 1864
3 months 5 days 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 (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .
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
$(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 .
Please Log in or Create an account to join the conversation.
3 months 5 days ago #176953
by krosser
I'm using the latest LS 3.15 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.15 hosted on LS servers, not installed locally.
Please Log in or Create an account to join the conversation.
- DenisChenu
-
- Away
- LimeSurvey Community Team
-
Less
More
- Posts: 10512
- Karma: 408
- Thank you received: 1864
3 months 4 days 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 (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .
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 (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.