Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Value check for Van-Westendorp pricing question

  • Lisios
  • Lisios's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 months 1 week ago #265604 by Lisios
Please help us help you and fill where relevant:
Your LimeSurvey version: 6.5.14
Own server or LimeSurvey hosting: Cloud version
Survey theme/template: Fruity
==================

Hello,

I am a complete newbie when it comes to LimeSurvey. I have now created a survey in which we want to determine prices using the Van Westendorp method.

I have selected "Multiple numerical input" as the question type and defined four sub-questions in which the participants have to enter a price in each case. I have selected the slider as display option (not a must, but nicer). Now I would like to check the values entered by the participants to ensure that the value of sub-question 1 > sub-question 2 > sub-question 3 > sub-question 4. If the check fails, a message should appear asking the participants to change their input.

I have now found and tried various instructions that solve the problem with JavaScript, but none of them have worked. Are there other options or are the JavaScript solutions no longer up to date?

Here is one solution that I have tried: 
manual.limesurvey.org/Workarounds:_Manip...meSurvey_version_3.x

ChatGTP suggested the following code:
Code:
<script type="text/javascript">
$(document).ready(function() {
function validateVanWestendorp() {
var answer1 = parseFloat($('input[name="questioncode_SQ001"]').val());
var answer2 = parseFloat($('input[name="questioncode_SQ002"]').val());
var answer3 = parseFloat($('input[name="questioncode_SQ003"]').val());
var answer4 = parseFloat($('input[name="questioncode_SQ004"]').val());
 
if (isNaN(answer1) || isNaN(answer2) || isNaN(answer3) || isNaN(answer4)) {
return false; // Ensure all inputs are filled
}
if (answer1 > answer2 &amp;amp;&amp;amp; answer2 > answer3 &amp;amp;&amp;amp; answer3 > answer4) {
return true;
} else {
alert('Bitte stellen Sie sicher, dass Antwort 1 > Antwort 2 > Antwort 3 > Antwort 4 ist.');
return false;
}
}
 
$('input[name="questioncode_SQ001"], input[name="questioncode_SQ002"], input[name="questioncode_SQ003"], input[name="questioncode_SQ004"]').on('blur', function() {
validateVanWestendorp();
});
 
$('#movenextbtn').click(function(event) {
if (!validateVanWestendorp()) {
event.preventDefault();
}
});
});
</script>
 
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 months 1 week ago #265606 by Joffm
Please, do not cross post!

Already answered in the German part.

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: DenisChenu
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team & Official Partner
  • LimeSurvey Community Team & Official Partner
More
2 months 6 days ago #265643 by DenisChenu
Replied by DenisChenu on topic Value check for Van-Westendorp pricing question

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member.
I don't answer to private message.
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose