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

TOPIC: Compute value in question hide

Compute value in question hide 2 years 6 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.

Re: Compute value in question hide 2 years 6 months ago #66036

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5279
  • Thank you received: 289
  • Karma: 246
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.

Re: Compute value in question hide 2 years 6 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.

Re: Compute value in question hide 2 years 6 months ago #66075

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5279
  • Thank you received: 289
  • Karma: 246
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.

Re: Compute value in question hide 2 years 6 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.

Re: Compute value in question hide 2 years 6 months ago #66087

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 81
  • Karma: 36
Computing and saving values will be much easier in LimeSurvey 1.92. Here are some good examples.
Last Edit: 2 years 6 months ago by TMSWhite.
The administrator has disabled public write access.

Re: Compute value in question hide 2 years 6 months ago #66092

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5279
  • Thank you received: 289
  • Karma: 246
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.

Re: Compute value in question hide 2 years 6 months ago #66097

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 3813
  • Thank you received: 683
  • Karma: 328
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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Re: Compute value in question hide 2 years 6 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.

Re: Compute value in question hide 2 years 6 months ago #66103

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 3813
  • Thank you received: 683
  • Karma: 328
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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Moderators: ITEd
Time to create page: 0.177 seconds
Donation Image