Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: Hide/Remove Question Help If Empty

Hide/Remove Question Help If Empty 1 year 4 months ago #95931

  • kobaltz
  • kobaltz's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 24
  • Thank you received: 4
  • Karma: 1
I'm trying to hide the question help if no text was entered. I think that it will overall help the look and feel of the survey.



In my question.pstpl file, I have created an ID for each question helper. I then use javascript to check to see if its contents are empty. If so, then hide the element. However, it's not working. Here is what I have.
<tr><td class="survey-question-help" id=help_{QUESTION_CLASS}>{QUESTIONHELP}</td></tr>

<script>
$(document).ready(function(){
  if($('#help_{QUESTION_CLASS}').val().length == 0){
  $('#help_{QUESTION_CLASS}').hide();
  }
});
</script>
The administrator has disabled public write access.

Hide/Remove Question Help If Empty 1 year 4 months ago #95934

  • kobaltz
  • kobaltz's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 24
  • Thank you received: 4
  • Karma: 1
It is actually working. It just took my page a while to refresh. I suppose loading javascript after a page fully loads could display the boxes there until then. However, now it seems a bit random as to which questions will hide their text. They have unique code names.


<div id="question8545" class="text-short mandatory">
<table class="question-wrapper">
<tbody>
<tr>
<td>
<table cellspacing="0" width="100%">
<tbody>
<tr>
<td class="question-text">
<span class="qnumcode">5 </span>
<span class="asterisk">*</span>
Who is your primary contact with the payroll company?
<br>
<span class="questionhelp"></span>
<span id="vmsg_8545" class="questionhelp hide-tip"></span>
</td>
</tr>
<tr>
<td id="help_text-short" class="survey-question-help"></td>
</tr>
<tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
<script>
$(document).ready(function(){
if($('#help_text-short').val().length == 0){
$('#help_text-short').hide();
}
});
</script>
Last Edit: 1 year 4 months ago by kobaltz. Reason: t
The administrator has disabled public write access.

Hide/Remove Question Help If Empty 1 year 4 months ago #95935

  • kobaltz
  • kobaltz's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 24
  • Thank you received: 4
  • Karma: 1
I figured it out. I was using too generic of a code in the ID tag. Instead I referenced it off of the Question Number. I used the .is(':empty') check and it works perfectly now.
<script>
$(document).ready(function(){
  if($('#help_{QUESTION_NUMBER}').is(':empty')){
  $('#help_{QUESTION_NUMBER}').hide();
  }
});
</script>
The administrator has disabled public write access.

Hide/Remove Question Help If Empty 1 year 4 months ago #95942

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5325
  • Thank you received: 296
  • Karma: 249
Thanks for sharing your solution.

Please add this at manual -> workarounds ->JavaScript so it doesn't get lost when old forum posts are deleted.
Thanks!

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.

Hide/Remove Question Help If Empty 8 months 4 weeks ago #102804

  • MikeConom
  • MikeConom's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 39
  • Thank you received: 1
  • Karma: 0
kobaltz

its a nice idea to hide empty question.

for me i am looking to find a different solution.

The question help text to be hidden except the button(?).
when i press the hep button(?) then question help text to appear.
Have you a solution for this?

Thanks
The administrator has disabled public write access.

Hide/Remove Question Help If Empty 8 months 4 weeks ago #102825

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6334
  • Thank you received: 818
  • Karma: 243
Hi,

I do a push qome day ago in skeleyonquest, maybe you can use same system:

github.com/Shnoulle/skeletonquest/commit...ff02b25346858b1ecR13
{if(!empty(QUESTIONHELP),"<tr><td class='survey-question-help'>".QUESTIONHELP."</td></tr>","")}
Ele you don't need help_{QUESTION_NUMBER} , just use:
$('#question{QID} .survey-question-help').hide();
The administrator has disabled public write access.
The following user(s) said Thank You: MikeConom

Hide/Remove Question Help If Empty 8 months 4 weeks ago #102856

  • MikeConom
  • MikeConom's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 39
  • Thank you received: 1
  • Karma: 0
Denis

Thanks for your responce

Is it possible in your example to be visible only the
X_Boilerpl.jpg

question mark and when i press it to be visible the help text ?
The administrator has disabled public write access.

Hide/Remove Question Help If Empty 8 months 3 weeks ago #102921

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6334
  • Thank you received: 818
  • Karma: 243
Not with my example.

Need some js here.

Look at jquery documentation : api.jquery.com/

Denis
The administrator has disabled public write access.

Hide/Remove Question Help If Empty 8 months 3 weeks ago #102925

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4193
  • Thank you received: 789
  • Karma: 359
Mike, here is an example of how to toggle the visibility of the help text when the image is clicked (this is for the default template and may need to be modified for other templates).

1) Add this to the end of template.js:
$(document).ready(function(){
 
	// Wrap the help text in a <span> element (excluding the help image)
	$('.survey-question-help').wrapInner('<span class="helpText" />');
	$('.survey-question-help').each(function(i) {
		$('img:eq(0)', this).addClass('helpImage');
		$(this).prepend($('img:eq(0)', this));
	});
 
	// Toggle the visibility of the help text
	$('.helpImage').click(function(event) {
		$(this).parent().find('.helpText').fadeToggle(600);
	});
 
	// Show the help element
	$('.survey-question-help').show();
});

2) Add this to the end of template.css:
.survey-question-help,
.survey-question-help .helpText {
	display: none;
}
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Last Edit: 8 months 3 weeks ago by tpartner.
The administrator has disabled public write access.
The following user(s) said Thank You: MikeConom

Hide/Remove Question Help If Empty 8 months 2 weeks ago #103164

  • MikeConom
  • MikeConom's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 39
  • Thank you received: 1
  • Karma: 0
Tony, i am working with limespired and i changed only this

$('.survey-question-help').wrapInner('<span class="helpText" style="display: none;" />');
Last Edit: 8 months 2 weeks ago by MikeConom.
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Moderators: ITEd
Time to create page: 0.387 seconds
Donation Image