Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: Can't get pre-filled text field to work

Can't get pre-filled text field to work 2 years 6 months ago #79860

  • audiolime
  • audiolime's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 17
  • Karma: 0
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
The administrator has disabled public write access.

Re: Can't get pre-filled text field to work 2 years 6 months ago #79862

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
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.
The administrator has disabled public write access.

Re: Can't get pre-filled text field to work 2 years 6 months ago #79863

  • audiolime
  • audiolime's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 17
  • Karma: 0
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
The administrator has disabled public write access.

Re: Can't get pre-filled text field to work 2 years 6 months ago #79865

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
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
The administrator has disabled public write access.

Re: Can't get pre-filled text field to work 2 years 6 months ago #79866

  • audiolime
  • audiolime's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 17
  • Karma: 0
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?
The administrator has disabled public write access.

Re: Can't get pre-filled text field to work 2 years 6 months ago #79867

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
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).
The administrator has disabled public write access.

Re: Can't get pre-filled text field to work 2 years 6 months ago #79870

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6551
  • Thank you received: 869
  • Karma: 257
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
The administrator has disabled public write access.

Re: Can't get pre-filled text field to work 2 years 6 months ago #79879

  • audiolime
  • audiolime's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 17
  • Karma: 0
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: 2 years 6 months ago by audiolime. Reason: I checked if the demo survey's default values work for me. They do.
The administrator has disabled public write access.

Re: Can't get pre-filled text field to work 2 years 6 months ago #79881

  • audiolime
  • audiolime's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 17
  • Karma: 0
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!
The administrator has disabled public write access.

Re: Can't get pre-filled text field to work 2 years 6 months ago #79901

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6551
  • Thank you received: 869
  • Karma: 257
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.

;)
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Moderators: ITEd
Time to create page: 0.180 seconds
Donation Image