Welcome to the LimeSurvey Community Forum

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

Freeze a text field once it's been answered/saved

  • mascarpone
  • mascarpone's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
6 years 2 months ago #163137 by mascarpone
Hi Folks!

I would like to know whether it is possible to "freeze" a text field (or any answer field really) once it's been answered - by greying it out for example?

Has anybody faced this?

Cheers ;)
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 2 months ago #163140 by holch
Could you be a little bit more specific?

If you don't allow to go back, then people can't change the text field, so it is frozen.

Now, if people can go back, then they can change the field. In this case: When do you consider the field "filled"? When should the field be frozen? When people move to the next page?

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.
  • mascarpone
  • mascarpone's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
6 years 2 months ago - 6 years 2 months ago #163141 by mascarpone
Replied by mascarpone on topic Freeze a text field once it's been answered/saved
Exactly holch, users could edit these fields as much as they want until they move to the next page/save the results in the DB. Then on, these results would only be visible but no longer editable (basically the greying would only apply to fields that already contain a value)

Is that clearer at all?
Last edit: 6 years 2 months ago by mascarpone.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 2 months ago #163165 by tpartner
For a long-text type question, you can try adding something like this to the question source. It will test for a value in the textarea and, if found, will disable it.

Code:
<script type="text/javascript" charset="utf-8">
  $(document).ready(function() {
 
    $('#question{QID} textarea').each(function(i) {
      if($.trim($(this).val()) != '') {
        $(this).prop('readonly', true).css('opacity', '0.3');
      }
    });
 
  });
</script>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • mascarpone
  • mascarpone's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
6 years 2 months ago #163174 by mascarpone
Replied by mascarpone on topic Freeze a text field once it's been answered/saved
Great will try that, thanks a lot tpartner!
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose