Can't get pre-filled text field to work

More
4 years 10 months ago #79860 by audiolime
Dear Limesurvey-Community,

I'd like to have my respondents edit a given sentence, so I'd like to set the default value for my text field to a specific sentence. I found some previous posts like that in the forum, however, none of the solutions worked for me.

Amongst them was this: www.limesurvey.org/en/forum/can-i-do-thi...1-pre-fill-textfield

From where I took this code:
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
var QQ= {3156}; // put the right question number
$("#question"+ QQ + "textarea.textarea").val("The monkey at the, seeing the banana in Christina's hand, grabbed at it through the bars.");}
)
</script>

I put it in the source code of a short text-question, but the sentence does not appear when I preview it. What's wrong with my code?
Esther

Please Log in to join the conversation.

More
4 years 10 months ago #79862 by TMSWhite
You can now set default values for text and multiple text question types. So, you don't need the JavaScript at all. Just use the default button to specify the initial text that should display.

Please Log in to join the conversation.

More
4 years 10 months ago #79863 by audiolime
Could it be that this was not yet included in the earlier release candidates? I can't find a "Default Value" field anywhere. I'm using Version 1.92 RC3 Build 12204

Please Log in to join the conversation.

More
4 years 10 months ago #79865 by TMSWhite
Yes, you should updated to 1.92+, which is a stable release and has many bug fixes (plus some new features like those defaults). www.limesurvey.org/en/download

Please Log in to join the conversation.

More
4 years 10 months ago #79866 by audiolime
I've been dreading to update because I read in the update notes that custom javascript code might not be compatible any more ( docs.limesurvey.org/Upgrade+hints+for+version+1.92 )
I have lots of javascript code in multiple surveys, it would be a nightmare to have to update all of them. Or will that be no problem since they already run in 1.92 RC3?

Please Log in to join the conversation.

More
4 years 10 months ago #79867 by TMSWhite
That was already an issue in the RC you have, but later releases helped mitigate some of those issues. So, if your JavaScript is working fine in RC3, it should also be fine in 1.92+. Easiest way to check is to load your survey into the Demo site (or clone your system onto a development box and upgrade it there - that way you don't mess up anything in production).

Please Log in to join the conversation.

More
4 years 10 months ago #79870 by DenisChenu
Hello,

Like Tom already say, usee default value in 1.92 are the best solution. In general javascript workaroundwork, need just some adaptatio with line feed after {.

You'r script are bad:
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
var QQ= "3156"; // put the right question number
$("#question"+QQ+ " textarea.textarea").val("The monkey at the, seeing the banana in Christina's hand, grabbed at it through the bars.");
});
</script>

Use a Release Candidate (RC) is really a bad idea.

Denis

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).

Please Log in to join the conversation.

More
4 years 10 months ago - 4 years 10 months ago #79879 by audiolime
Thanks, I updated and my old surveys still work like a charm.
However, I still can't get the default value to work.

I made a new survey, new question group, new question of type "short free text", saved it and then clicked on "set default value" to set the initial value for the text field.
There I just typed the sentence I want my responders to see. I hit save & and the small popup says the default value has been saved. When I open it again, it's gone and it does not show up in the question preview.

I can see & change the default value in the Demo survey.

I'm sure I'm missing something simple, but what is it?
Last Edit: 4 years 10 months ago by audiolime. Reason: I checked if the demo survey's default values work for me. They do.

Please Log in to join the conversation.

More
4 years 10 months ago #79881 by audiolime
Ok, I solved it myself by creating a new survey (the old survey had been created in 1.92 RC3). Don't know why that makes a difference, but it does work now. Thanks anyways, limesurvey is great!

Please Log in to join the conversation.

More
4 years 10 months ago #79901 by DenisChenu

audiolime wrote: Don't know why that makes a difference, but it does work now.

DenisChenu wrote: Use a Release Candidate (RC) is really a bad idea.


;)

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).

Please Log in to join the conversation.

More
4 years 10 months ago #80109 by Mazi
If you want to show the given answer at a following question, have a look at this blog post: www.limesurvey-consulting.com/pre-fillin...xpression-manager-2/


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in to join the conversation.