Prevent editing of text field

Plus d'informations
il y a 1 mois 3 jours #192650 par ch123
Hey. Again me with another question ;)
My survey has a short explanation text and on this basis first an open text field and then several single choice questions. Sometimes the single choice questions repeat a part of the open text question. That's why I want to prevent participants from editing their written text.
My ideas to do it:
1) Disable the previous button. Found this thread and it worked. But of course with it it's not possible to go back to other parts of the survey (as this text comprehension task is just a short part of the whole survey). So is it possible with this js-code to skip the page with the text field, but still go further back to the other parts?
2) Prevent editing the text field with grey out or something. So after validating the answer with pressing "next" it shouldn't be possible to do any changes...
Is it possible to do this?
Thanks in advance! :)

Connexion ou Créer un compte pour participer à la conversation.

LimeSurvey Partners
Plus d'informations
il y a 1 mois 3 jours #192655 par Joffm
Réponse de Joffm sur le sujet Prevent editing of text field
Hi,
my idea is - as usual only with built-in functions - to store the entered text in a hidden question of the same type.

1. There is the question "Open1"
2. create a hidden question of the same type "Open2"
Now create two hidden equations:
3. Store the value of "Open1" into "Open2", BUT ONLY if "Open2" is still empty.
Equation: {Open2=if(is_empty(Open2),Open1,Open2)}
4. Restore "Open2" into "Open1"
Equation: {Open1=Open2}
So, if "Open1" was changed, the "old" value is entered again.

Example. You will see, the first entered text doesn't change.

Fichier attaché :

Nom du fichier : limesurvey...7655.lss
Taille du ficher :17 ko


Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless
Pièces jointes :
Les utilisateur(s) suivant ont remercié: ch123

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 1 mois 3 jours #192663 par tpartner
Réponse de tpartner sur le sujet Prevent editing of text field
My solution, as usual, includes JavaScript. :)

On page load, if the text element is not empty, disable it.

For a long-text question, something like this in the question source:

<script type="text/javascript" charset="utf-8">
 
	$(document).on('ready pjax:scriptcomplete',function(){
 
		if($.trim($('#question{QID} textarea:eq(0)').val()) != '') {
			$('#question{QID} textarea:eq(0)').prop('readonly', true);
		}
    });
</script>

For a short-text question, something like this in the question source:

<script type="text/javascript" charset="utf-8">
 
	$(document).on('ready pjax:scriptcomplete',function(){
 
		if($.trim($('#question{QID} input:text:eq(0)').val()) != '') {
			$('#question{QID} input:text:eq(0)').prop('readonly', true);
		}
    });
</script>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Official LimeSurvey Partner - partnersurveys.com
Les utilisateur(s) suivant ont remercié: ch123

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 1 mois 3 jours #192666 par Joffm
Réponse de Joffm sur le sujet Prevent editing of text field

My solution, as usual, includes JavaScript

:lol: :lol: :lol:

Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 1 mois 2 jours #192675 par ch123
Réponse de ch123 sur le sujet Prevent editing of text field
Both solutions are awesome - thanks a lot, Joffm & tpartner!
Now I have to decide which one works better for me :D

Connexion ou Créer un compte pour participer à la conversation.

Commencez dès maintenant !

Créez simplement un compte et commencez à utiliser LimeSurvey dès aujourd'hui.

Inscrivez-vous maintenant

Inscrivez-vous à notre Newsletter!