Willkommen, Gast
Benutzername: Passwort: Angemeldet bleiben:

THEMA: hide question if prefilled

hide question if prefilled 7 Monate 2 Tage her #99927

  • andrewz
  • andrewzs Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 2
  • Karma: 0
I prefill one answer using a URL like this

www.example/index.php/survey/index/sid/7...712544X99X2152=12345

Then I set the "always hide" option. Most of the time, this works, but sometimes the parameters are missing, so the answer is blank.

When it is blank, I want to unhide the question. I tried using a relevance equation of !is_empty(foo), but this seems to always hide the question and break recording of the answer in both cases.

Version 2.00+ Build 130913
Der Administrator hat öffentliche Schreibrechte deaktiviert.

hide question if prefilled 7 Monate 2 Tage her #99936

  • tpartner
  • tpartners Avatar
  • ONLINE
  • LimeSurvey Team
  • Beiträge: 3817
  • Dank erhalten: 683
  • Karma: 328
I don't think you want to use relevance because the question should always be relevant, whether pre-populated or not.

Assuming it is a short-text question, try not using the "always hide" option, set up your survey to use JavaScript and add this to the question source:
<script type="text/javascript" charset="utf-8">	
	$(document).ready(function() {
		if($('#question{QID} input.text').val() == '') {
			$('#question{QID}.hide();
		}
	});	
</script>


Of course, this will also hide the question if a respondent answers it, moves on in the survey and then returns to the group later.
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.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

hide question if prefilled 7 Monate 1 Tag her #99947

  • DenisChenu
  • DenisChenus Avatar
  • OFFLINE
  • Moderator Lime
  • Beiträge: 5854
  • Dank erhalten: 716
  • Karma: 222
Hi,

Think i use 2 question.
First with hide settings prefilled by URL
Second : is_empty(FIRST)

ANd maybe a 2rd equation question type:
{FIRST.NAOK}{SECOND.NAOK}

Denis
Der Administrator hat öffentliche Schreibrechte deaktiviert.

hide question if prefilled 7 Monate 17 Stunden her #99990

  • andrewz
  • andrewzs Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 2
  • Karma: 0
Denis, this sounds like what I came up with.

I added a second question which is irrelevant when the first question is not empty.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

hide question if prefilled 3 Monate 3 Wochen her #102944

  • dweisser
  • dweissers Avatar
  • OFFLINE
  • Silver Donor
  • Beiträge: 182
  • Dank erhalten: 5
  • Karma: 5
I would like to hide the question if a textarea has been filled.

I'm using a question with a timer. It is the only question in the category.
I thought I had this working...
<script type="text/javascript" charset="utf-8">	
$(document).ready(function() {
  if($('#answer724821X200X1391').length > 0) {
			$('#question1391').hide();
alert($('#answer724821X200X1391').attr('value'));
  }
});
</script>

But it hides the question whether there is any text in the textarea or not. Any thoughts would be most appreciated. Thanks for maintaining such a great resource.
David
Letzte Änderung: 3 Monate 3 Wochen her von dweisser.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

hide question if prefilled 3 Monate 3 Wochen her #102945

  • tpartner
  • tpartners Avatar
  • ONLINE
  • LimeSurvey Team
  • Beiträge: 3817
  • Dank erhalten: 683
  • Karma: 328
Try:
if($('#answer724821X200X1391').val() != '') {
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.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

hide question if prefilled 3 Monate 3 Wochen her #102964

  • dweisser
  • dweissers Avatar
  • OFFLINE
  • Silver Donor
  • Beiträge: 182
  • Dank erhalten: 5
  • Karma: 5
That did the trick.

You know, I was trying that at one point, but I was trying to extend the if statement to handle a Default Answer.
So:
<script type="text/javascript" charset="utf-8">	
$(document).ready(function() {
if(($('#answer724821X200X1391').val() != '') or ($('#answer724821X200X1391').val() != 'Enter your response here.')) {
			$('#question1391').hide();
//alert($('#answer724821X200X1391').attr('value'));
  }
});
</script>

But, it didn't work. I just got rid of the Default answer and all is well.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

hide question if prefilled 3 Monate 2 Wochen her #102973

  • tpartner
  • tpartners Avatar
  • ONLINE
  • LimeSurvey Team
  • Beiträge: 3817
  • Dank erhalten: 683
  • Karma: 328
For a default answer in a text question, try:

if($('#answer724821X200X1391').val() != '' && $('#answer724821X200X1391').val() != 'Enter your response here.') {
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.
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Moderatoren: ITEd
Ladezeit der Seite: 0.277 Sekunden
Donation Image