Welcome to the LimeSurvey Community Forum

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

Disable buttons when one is selected

  • fjusufi
  • fjusufi's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 4 weeks ago #195639 by fjusufi
Disable buttons when one is selected was created by fjusufi
Hello,

Can anyone help, I found a script for the radio inputs but it doesn't work in v4.1.8 using bootstrap buttons.

What I want is to disable the option buttons when you click on one and then show the right answer if it was wrong.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 4 weeks ago #195640 by Joffm
Replied by Joffm on topic Disable buttons when one is selected

I found a script for the radio inputs

How can we help if you do not show the script?

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • fjusufi
  • fjusufi's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 4 weeks ago #195641 by fjusufi
Replied by fjusufi on topic Disable buttons when one is selected
// A function to disable all non-checked radios
function handleDisableNonChecked(thisRadio) {
var thisRow = $(thisRadio).closest('.answer-item');
// Disable non-checked radios
$('#question{QID} input.radio').not(thisRadio).prop('disabled', true);
// Handle "Other" text input
if($('input.text', thisRow).length == 0) {
$('#question{QID} input.text').prop('disabled', true);
}
// Add a class to the disabled rows
$('#question{QID} .answer-item').not(thisRow).addClass('disabled-row');
}

// Initial state (in case of returning to page
if($('#question{QID} input.radio:checked').length > 0) {
handleDisableNonChecked($('#question{QID} input.radio:checked'));
}

// Listener on the radios
$('#question{QID} input.radio').on('click', function(e){
handleDisableNonChecked(this);
});

// Fix the core event handler for the label div
$('#question{QID} .label-clickable').unbind('click').on('click', function(e){
if(!$(this).parent().find('input.radio').is(':disabled')) {
$(this).parent().find('input.radio').trigger('click');
}
});
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 4 weeks ago #195649 by Joffm
Replied by Joffm on topic Disable buttons when one is selected
Hi,
please always show the entire script, which you obviously found here
www.limesurvey.org/forum/can-i-do-this-w...ter-selection#136891

This script is for version 2.50/2.73. So you cannot expect it to work.
And you may have read - if you look for scripts - that
input.radio changed to input[type="radio"]
Other types as well.

So, what I do in these cases, I change accordingly, and try.
And: it works.

Tested in 4.1.11

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • fjusufi
  • fjusufi's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 4 weeks ago #195650 by fjusufi
Replied by fjusufi on topic Disable buttons when one is selected
Ok, thanks, I tried, changed to input[type="radio"], and changed the type of the question to radio and it works, but I want to use bootstrap buttons and I tried to change input[type="radio"] to .bootstrap-buttons-div but it doesn't work!
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 4 weeks ago #195654 by tpartner
Replied by tpartner on topic Disable buttons when one is selected
Why would you do this? What if a respondent clicks a button by mistake?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: DenisChenu
The topic has been locked.
  • fjusufi
  • fjusufi's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 4 weeks ago #195656 by fjusufi
Replied by fjusufi on topic Disable buttons when one is selected
It is a quiz, and we want to have only one answer so we can show the results at the end.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 4 weeks ago #195663 by Joffm
Replied by Joffm on topic Disable buttons when one is selected
1. Use a simple question and show - as you do - the results at the end.
Here is the place to show what's right or wrong.

2. Use a simple question and show a text display question afterwards in case the answer was wrong with an explanation.

3. Use the provided solution with radio buttons

but I want to use bootstrap buttons

I want to have a Lamborghini. ;)

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • fjusufi
  • fjusufi's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 4 weeks ago #195665 by fjusufi
Replied by fjusufi on topic Disable buttons when one is selected
The shpwing of correct and incorrect text I have it in the same question view, all I need is this so I can disable the buttons which were not clicked.

P.S. The forums are to help people in regards to what they want to achieve from the system, I was not speaking of what I want in life!!!! anyways thanks.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 4 weeks ago - 4 years 4 weeks ago #195667 by tpartner
Replied by tpartner on topic Disable buttons when one is selected

P.S. The forums are to help people in regards to what they want to achieve from the system

Please keep in mind that the people helping you here are VOLUNTEERS helping in their free time with your free software.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 4 years 4 weeks ago by tpartner.
The topic has been locked.
  • fjusufi
  • fjusufi's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 4 weeks ago #195668 by fjusufi
Replied by fjusufi on topic Disable buttons when one is selected
I'm very thankfull for that, that's why I said thanks many times.

I hope we're not going to speak about this anymore but instead hopefully will have a solution for me, thanks.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 4 weeks ago #195674 by DenisChenu
Replied by DenisChenu on topic Disable buttons when one is selected

tpartner wrote: Why would you do this? What if a respondent clicks a button by mistake?

And keyboard web user ...

@fjusufi : i never tell user how broke internet for disable user.

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.

Lime-years ahead

Online-surveys for every purse and purpose