- Posts: 38
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
th.answertext - display if empty
- stemate1988
- Topic Author
- Offline
- Junior Member
Less
More
8 years 3 weeks ago - 8 years 3 weeks ago #132598
by stemate1988
th.answertext - display if empty was created by stemate1988
Subject should be: Display as hidden if empty
Evening,
for 10 point or 5 point array questions if the question text is blank a box is still displayed on the page.
this can be shrunk down in the advanced section to 0 however it would like a lot nicer if it was hidden.
Is there any javascript that could hide all of these elements if they are empty?
Much appreciated
Evening,
for 10 point or 5 point array questions if the question text is blank a box is still displayed on the page.
this can be shrunk down in the advanced section to 0 however it would like a lot nicer if it was hidden.
Is there any javascript that could hide all of these elements if they are empty?
Much appreciated
Attachments:
Last edit: 8 years 3 weeks ago by stemate1988. Reason: error
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10634
- Thank you received: 3698
8 years 3 weeks ago #132606
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic th.answertext - display if empty
LimeSurvey version?
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- stemate1988
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 38
- Thank you received: 0
8 years 3 weeks ago #132625
by stemate1988
Replied by stemate1988 on topic th.answertext - display if empty
2.00+
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10634
- Thank you received: 3698
8 years 3 weeks ago #132648
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic th.answertext - display if empty
1) Add this to the end of template.js (so it can be used for multiple questions):
2) Call the function with this script in the question text of the array:
3) Since it appears that you are using the citronade template, add this to the end of template.css:
Code:
function removeAnswerText(qID) { // Identify some stuff var thisQuestion = $('#question'+qID); var thisArray = $('table.questions-list', thisQuestion); // Only if all row labels are empty var labelsWithText = $('th.answertext', thisArray).filter(function(i) {return $.trim($(this).text()) != '';}).length if(labelsWithText == 0) { // Add a class to the question thisQuestion.addClass('without-answertext'); // Remove the first column $('.col-answers, thead td:eq(0), th.answertext', thisArray).remove(); //Reset the column widths $('col', thisArray).attr('width', 100/$('col', thisArray).length+'%'); } }
2) Call the function with this script in the question text of the array:
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ removeAnswerText({QID}); }); </script>
3) Since it appears that you are using the citronade template, add this to the end of template.css:
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- stemate1988
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 38
- Thank you received: 0
8 years 3 weeks ago #132650
by stemate1988
Replied by stemate1988 on topic th.answertext - display if empty
Cheers for this, I have put the code in the relevant places however it is coming out as the attached. I have cleared the cache just in case also.
I am using a customised skeletonquest template, not sure if this would affect it.
I am using a customised skeletonquest template, not sure if this would affect it.
Attachments:
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10634
- Thank you received: 3698
8 years 3 weeks ago #132662
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic th.answertext - display if empty
Can you activate a test survey and give us a link?
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- stemate1988
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 38
- Thank you received: 0
8 years 3 weeks ago - 8 years 3 weeks ago #132663
by stemate1988
Replied by stemate1988 on topic th.answertext - display if empty
Last edit: 8 years 3 weeks ago by stemate1988.
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11758
- Thank you received: 2753
8 years 3 weeks ago #132664
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic th.answertext - display if empty
This doesn't lead to the demo survey, but to the login screen of the demo server.
Which of the surveys on this installation is yours?
Which of the surveys on this installation is yours?
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The topic has been locked.
- stemate1988
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 38
- Thank you received: 0
8 years 3 weeks ago #132665
by stemate1988
Replied by stemate1988 on topic th.answertext - display if empty
edited my previous message, should be able to access directly now
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10634
- Thank you received: 3698
8 years 3 weeks ago #132666
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic th.answertext - display if empty
Hmm...seems that in your LS version there is no <td> element th the <thead>.
Try this as the function in template.js:
Try this as the function in template.js:
Code:
function removeAnswerText(qID) { // Identify some stuff var thisQuestion = $('#question'+qID); var thisArray = $('table.questions-list', thisQuestion); // Only if all row labels are empty var labelsWithText = $('th.answertext', thisArray).filter(function(i) {return $.trim($(this).text()) != '';}).length if(labelsWithText == 0) { // Add a class to the question thisQuestion.addClass('without-answertext'); // Remove the first column $('.col-answers, thead tr:eq(0) > *:eq(0), th.answertext', thisArray).remove(); //Reset the column widths $('col', thisArray).attr('width', 100/$('col', thisArray).length+'%'); } }
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: stemate1988
The topic has been locked.
- stemate1988
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 38
- Thank you received: 0
8 years 3 weeks ago #132668
by stemate1988
Replied by stemate1988 on topic th.answertext - display if empty
That's worked thanks a lot for that, appreciate the help!
The topic has been locked.