Willkommen, Gast
Benutzername: Passwort: Angemeldet bleiben:
  • Seite:
  • 1
  • 2

THEMA: Hide/Remove Question Help If Empty

Hide/Remove Question Help If Empty 11 Monate 1 Woche her #95931

  • kobaltz
  • kobaltzs Avatar
  • OFFLINE
  • Junior Lime
  • Beiträge: 24
  • Dank erhalten: 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>
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Hide/Remove Question Help If Empty 11 Monate 1 Woche her #95934

  • kobaltz
  • kobaltzs Avatar
  • OFFLINE
  • Junior Lime
  • Beiträge: 24
  • Dank erhalten: 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>
Letzte Änderung: 11 Monate 1 Woche her von kobaltz. Begründung: t
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Hide/Remove Question Help If Empty 11 Monate 1 Woche her #95935

  • kobaltz
  • kobaltzs Avatar
  • OFFLINE
  • Junior Lime
  • Beiträge: 24
  • Dank erhalten: 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>
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Folgende Benutzer bedankten sich: flashmanblack

Hide/Remove Question Help If Empty 11 Monate 1 Woche her #95942

  • Mazi
  • Mazis Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 5279
  • Dank erhalten: 289
  • Karma: 246
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'"
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Hide/Remove Question Help If Empty 4 Monate 19 Stunden her #102804

  • MikeConom
  • MikeConoms Avatar
  • OFFLINE
  • Junior Lime
  • Beiträge: 33
  • Dank erhalten: 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
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Hide/Remove Question Help If Empty 4 Monate 2 Stunden her #102825

  • DenisChenu
  • DenisChenus Avatar
  • OFFLINE
  • Moderator Lime
  • Beiträge: 5866
  • Dank erhalten: 718
  • Karma: 222
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();
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Folgende Benutzer bedankten sich: MikeConom

Hide/Remove Question Help If Empty 3 Monate 4 Wochen her #102856

  • MikeConom
  • MikeConoms Avatar
  • OFFLINE
  • Junior Lime
  • Beiträge: 33
  • Dank erhalten: 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 ?
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Hide/Remove Question Help If Empty 3 Monate 3 Wochen her #102921

  • DenisChenu
  • DenisChenus Avatar
  • OFFLINE
  • Moderator Lime
  • Beiträge: 5866
  • Dank erhalten: 718
  • Karma: 222
Not with my example.

Need some js here.

Look at jquery documentation : api.jquery.com/

Denis
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Hide/Remove Question Help If Empty 3 Monate 3 Wochen her #102925

  • tpartner
  • tpartners Avatar
  • ONLINE
  • LimeSurvey Team
  • Beiträge: 3837
  • Dank erhalten: 688
  • Karma: 330
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.
Letzte Änderung: 3 Monate 3 Wochen her von tpartner.
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Folgende Benutzer bedankten sich: MikeConom

Hide/Remove Question Help If Empty 3 Monate 2 Wochen her #103164

  • MikeConom
  • MikeConoms Avatar
  • OFFLINE
  • Junior Lime
  • Beiträge: 33
  • Dank erhalten: 1
  • Karma: 0
Tony, i am working with limespired and i changed only this

$('.survey-question-help').wrapInner('<span class="helpText" style="display: none;" />');
Letzte Änderung: 3 Monate 2 Wochen her von MikeConom.
Der Administrator hat öffentliche Schreibrechte deaktiviert.
  • Seite:
  • 1
  • 2
Moderatoren: ITEd
Ladezeit der Seite: 0.505 Sekunden
Donation Image