- Posts: 5
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Skip mandatory questions via script
- kensikat
- Topic Author
- Offline
- New Member
Less
More
5 years 8 months ago #172051
by kensikat
Skip mandatory questions via script was created by kensikat
Hi everybody,
I'm setting a cookie via js so that participants who take the survey again dont have to answer the first two pages again (I want participants to take the survey more than once).
I know how to skip a page by activating the next button in my script. However it doesnt work when the questions are set to be mandatory.
I want them to be mandatory for the first time, so setting them to be non-mandatory is not an option sadly.
Does anyone know how to disable the mandatory feature for all questions on a page via js?
I wasnt able to find an answer with my search of the forums.
Advice would be greatly appreciated!
Greetings,
Kaspar
I'm setting a cookie via js so that participants who take the survey again dont have to answer the first two pages again (I want participants to take the survey more than once).
I know how to skip a page by activating the next button in my script. However it doesnt work when the questions are set to be mandatory.
I want them to be mandatory for the first time, so setting them to be non-mandatory is not an option sadly.
Does anyone know how to disable the mandatory feature for all questions on a page via js?
I wasnt able to find an answer with my search of the forums.
Advice would be greatly appreciated!
Greetings,
Kaspar
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13597
- Thank you received: 2487
5 years 8 months ago #172056
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Skip mandatory questions via script
Just enter some value via js too …
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
- kensikat
- Topic Author
- Offline
- New Member
Less
More
- Posts: 5
- Thank you received: 0
5 years 8 months ago #172057
by kensikat
Replied by kensikat on topic Skip mandatory questions via script
That could work but is kind of an unelegant workaround. Since there are quite a few questions in different formats on those two that would be kind of a hassle. I was hoping for an easier solution.
Still, thank you for your quick answer. If there isnt any better solution, I'll have to go that way.
Still, thank you for your quick answer. If there isnt any better solution, I'll have to go that way.
The topic has been locked.
- kensikat
- Topic Author
- Offline
- New Member
Less
More
- Posts: 5
- Thank you received: 0
5 years 8 months ago #172060
by kensikat
Replied by kensikat on topic Skip mandatory questions via script
So, I found the option to remove the class "mandatory" from all elements.
var mandatoryelems = document.querySelectorAll(".mandatory");
alert(mandatoryelems.length);
[].forEach.call(mandatoryelems, function(el) {
el.classList.remove("mandatory");
});
Still a prompt appears that tells me that not all questions have been answered and stops me from activating the next button.
var mandatoryelems = document.querySelectorAll(".mandatory");
alert(mandatoryelems.length);
[].forEach.call(mandatoryelems, function(el) {
el.classList.remove("mandatory");
});
Still a prompt appears that tells me that not all questions have been answered and stops me from activating the next button.
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13597
- Thank you received: 2487
5 years 8 months ago #172061
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Skip mandatory questions via script
You use cookie … but if you use another system, for example token or prefill value by url or … etc …
You can use relevance on the first 2 group directly …
You can use relevance on the first 2 group directly …
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13597
- Thank you received: 2487
5 years 8 months ago #172062
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Skip mandatory questions via script
Mandatory system is tested via PHP … hopefully …
Then 2 solution:
- Set relevance to 0
- Put a value in answer
Then 2 solution:
- Set relevance to 0
- Put a value in answer
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
- kensikat
- Topic Author
- Offline
- New Member
Less
More
- Posts: 5
- Thank you received: 0
5 years 8 months ago #172064
by kensikat
Replied by kensikat on topic Skip mandatory questions via script
The first option sounds like the way to go.
Can you explain how I'd set that up to work? Or is there anything about it in the manual? If so, could you link it to me?
Thank you in advance!
Can you explain how I'd set that up to work? Or is there anything about it in the manual? If so, could you link it to me?
Thank you in advance!
The topic has been locked.