Hide/Remove Question Help If Empty

Mehr
4 Jahre 2 Wochen her #95931 von kobaltz
kobaltz erstellte das Thema Hide/Remove Question Help If Empty
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>

Bitte Anmelden um der Konversation beizutretten.

Mehr
4 Jahre 2 Wochen her - 4 Jahre 2 Wochen her #95934 von kobaltz
kobaltz antwortete auf das Thema: Hide/Remove Question Help If Empty
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: 4 Jahre 2 Wochen her von kobaltz. Begründung: t

Bitte Anmelden um der Konversation beizutretten.

Mehr
4 Jahre 2 Wochen her #95935 von kobaltz
kobaltz antwortete auf das Thema: Hide/Remove Question Help If Empty
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>

Bitte Anmelden um der Konversation beizutretten.

Mehr
4 Jahre 2 Wochen her #95942 von Mazi
Mazi antwortete auf das Thema: Hide/Remove Question Help If Empty
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)survey-consulting.com'"

Bitte Anmelden um der Konversation beizutretten.

Mehr
3 Jahre 5 Monate her #102804 von MikeConom
MikeConom antwortete auf das Thema: Hide/Remove Question Help If Empty
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

Bitte Anmelden um der Konversation beizutretten.

Mehr
3 Jahre 5 Monate her #102825 von DenisChenu
DenisChenu antwortete auf das Thema: Hide/Remove Question Help If Empty
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();

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 .
Folgende Benutzer bedankten sich: MikeConom

Bitte Anmelden um der Konversation beizutretten.

Mehr
3 Jahre 5 Monate her #102856 von MikeConom
MikeConom antwortete auf das Thema: Hide/Remove Question Help If Empty
Denis

Thanks for your responce

Is it possible in your example to be visible only the

question mark and when i press it to be visible the help text ?
Anhang:

Bitte Anmelden um der Konversation beizutretten.

Mehr
3 Jahre 5 Monate her #102921 von DenisChenu
DenisChenu antwortete auf das Thema: Hide/Remove Question Help If Empty
Not with my example.

Need some js here.

Look at jquery documentation : api.jquery.com/

Denis

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 .

Bitte Anmelden um der Konversation beizutretten.

Mehr
3 Jahre 5 Monate her - 3 Jahre 5 Monate her #102925 von tpartner
tpartner antwortete auf das Thema: Hide/Remove Question Help If Empty
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.
Letzte Änderung: 3 Jahre 5 Monate her von tpartner.
Folgende Benutzer bedankten sich: MikeConom

Bitte Anmelden um der Konversation beizutretten.

Mehr
3 Jahre 4 Monate her - 3 Jahre 4 Monate her #103164 von MikeConom
MikeConom antwortete auf das Thema: Hide/Remove Question Help If Empty
Tony, i am working with limespired and i changed only this

$('.survey-question-help').wrapInner('<span class="helpText" style="display: none;" />');
Letzte Änderung: 3 Jahre 4 Monate her von MikeConom.

Bitte Anmelden um der Konversation beizutretten.

Mehr
3 Jahre 4 Monate her #103168 von tpartner
tpartner antwortete auf das Thema: Hide/Remove Question Help If Empty
I prefer to do it with CSS, that way there is no "flash" as the JS hides the element.

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

Bitte Anmelden um der Konversation beizutretten.

Jetzt loslegen!

Melden Sie sich jetzt an, und erstellen Sie in wenigen Minuten Ihre erste Umfrage.

Account einrichten