Check out the LimeSurvey source code on GitHub!
Welcome, Guest
Username: Password:

TOPIC: Compute value in question hide

Compute value in question hide 4 years 11 months ago #66023

  • rafael_ur
  • rafael_ur's Avatar
  • Offline
  • Senior Lime
  • Posts: 74
  • Karma: 0
Hi,
I need, in question hide, compute a value a numerical question but script not working. This is the script:

script type="text/javascript" charset="utf-8">
$(document).ready(function(){
//numerical question 18921
var fp3ara = $('#question'+18921+' input.text').val();
//radio 1896
var q2ID = 1896;
//$('#question'+q2ID+'').hide();
if(Number(fp3ara) >= 50) {
$('#question'+q2ID+' input.radio:eq(0)').attr('checked', true);
}
else {
$('#question'+q2ID+' input.radio:eq(1)').attr('checked', true);
}
});
</script>

Can you help me?

Thank,
Rafael
The administrator has disabled public write access.

Compute value in question hide 4 years 11 months ago #66036

  • Mazi
  • Mazi's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5984
  • Thank you received: 368
  • Karma: 260
Well, the first thing I see is a missing opening "<" character at the code you posted.

For everything else you provide not enough information. A link to your survey to check the code live would help best.

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.

Compute value in question hide 4 years 11 months ago #66046

  • rafael_ur
  • rafael_ur's Avatar
  • Offline
  • Senior Lime
  • Posts: 74
  • Karma: 0
Hello Mazi,
Apologies, "<" was a mistake of copy paste.
Link to survey:
www.innovaim-online.com/limesurvey/index.php?sid=33632&lang=es
The script:
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
var fp3ara = $('#question'+19701+' input.text').val();

//$('#question'+q2ID+'').hide();
if(Number(fp3ara) == 50) {
$('#question'+q2ID+' input.radio:eq(0)').attr('checked', true);
}
else {
$('#question'+q2ID+' input.radio:eq(1)').attr('checked', true);
}
});
</script>
Thanks for your help.
Rafael
The administrator has disabled public write access.

Compute value in question hide 4 years 11 months ago #66075

  • Mazi
  • Mazi's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5984
  • Thank you received: 368
  • Karma: 260
I think you missed to define the ID of the second question ("q2ID")?

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.

Compute value in question hide 4 years 11 months ago #66080

  • rafael_ur
  • rafael_ur's Avatar
  • Offline
  • Senior Lime
  • Posts: 74
  • Karma: 0
HI,

This is script:
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
var fp3ara = $('#question'+19701+' input.text').val();
var q2ID = 1974;
//$('#question'+q2ID+'').hide();
if(Number(fp3ara) >= 50) {
$('#question'+q2ID+' input.radio:eq(0)').attr('checked', true);
}
else {
$('#question'+q2ID+' input.radio:eq(1)').attr('checked', true);
}
});
</script>
I don´t know to put the listener to a numerical question.
How can I do it?.
Thank,
Rafael.
The administrator has disabled public write access.

Compute value in question hide 4 years 11 months ago #66087

  • TMSWhite
  • TMSWhite's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 758
  • Thank you received: 83
  • Karma: 37
Computing and saving values will be much easier in LimeSurvey 1.92. Here are some good examples.
Last Edit: 4 years 11 months ago by TMSWhite.
The administrator has disabled public write access.

Compute value in question hide 4 years 11 months ago #66092

  • Mazi
  • Mazi's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5984
  • Thank you received: 368
  • Karma: 260
Have a look at manual -> workarounds ->JavaScript, there are several code examples.

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.

Compute value in question hide 4 years 11 months ago #66097

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6230
  • Thank you received: 1382
  • Karma: 539
Rafael, can you please explain what you are trying to accomplish?

It appears from your code and survey that if a number >= 50 is entered in the first input of a multiple-numeric question, you want the first radio of a following select-one question to be checked. Is this correct?

Can you attach a sample group?
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The administrator has disabled public write access.

Compute value in question hide 4 years 11 months ago #66101

  • rafael_ur
  • rafael_ur's Avatar
  • Offline
  • Senior Lime
  • Posts: 74
  • Karma: 0
Hi Toni, your explanation is correct.
If the first input of a multiple-numeric question is >=50, the following select-one question to be checked. I don't know how to put listener.

This is script:
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
var fp3ara = $('#question'+19701+' input.text').val();
var q2ID = 1974;
//$('#question'+q2ID+'').hide();

LISTENER???

if(Number(fp3ara) >= 50) {
$('#question'+q2ID+' input.radio:eq(0)').attr('checked', true);
}
else {
$('#question'+q2ID+' input.radio:eq(1)').attr('checked', true);
}
});
</script>

Many thanks.
Rafael
The administrator has disabled public write access.

Compute value in question hide 4 years 11 months ago #66103

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6230
  • Thank you received: 1382
  • Karma: 539
Try:
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function(){
 
		var q1ID = 1970; //Multi-numbers ID
		var q2ID = 1974; // Radio ID
 
		//$('#question'+q2ID+'').hide();
 
		// Listener on the first input of the multi-numbers
		$('#question'+q1ID+' input.text:eq(0)').change(function(){
 
			var fp3ara = $(this).val();
 
			if(fp3ara >= 50) {
				$('#question'+q2ID+' input.radio:eq(0)').attr('checked', true);
			}
			else {
				$('#question'+q2ID+' input.radio:eq(1)').attr('checked', true);
			}
		});
	});
 
</script>
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The administrator has disabled public write access.

Compute value in question hide 4 years 11 months ago #66104

  • rafael_ur
  • rafael_ur's Avatar
  • Offline
  • Senior Lime
  • Posts: 74
  • Karma: 0
Many thanks!!
It works perfectly.
Rafael
The administrator has disabled public write access.

Compute value in question hide 4 years 11 months ago #66119

  • Mazi
  • Mazi's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5984
  • Thank you received: 368
  • Karma: 260
You're welcome.

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.
Moderators: ITEd
Time to create page: 0.266 seconds
Imprint                   Data Protection Statement                  Revocation information and revocation form