- Posts: 22
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Letters counter
- helviobrito
- Topic Author
- Offline
- Junior Member
Less
More
8 years 7 months ago #125885
by helviobrito
Letters counter was created by helviobrito
Hi. I'd like to include a counter in text fields of limited sizes. For example: in a text question for 300 characters, a counter starts in 300 and, as respondent write, the counter shows number of characters are left till the end. Can anyone provide a solution?
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11658
- Thank you received: 2742
8 years 7 months ago #125887
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Letters counter
This is more a general web development question (javascript) rather than a Limesurvey question:
www.sitepoint.com/10-jquery-wordtext-counter-plugins/
www.sitepoint.com/10-jquery-wordtext-counter-plugins/
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.
- Ben_V
- Offline
- Platinum Member
Less
More
- Posts: 1128
- Thank you received: 329
8 years 7 months ago - 8 years 7 months ago #125888
by Ben_V
Benoît
EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
Replied by Ben_V on topic Letters counter
For a text question with question code "qtext" (200 chars. max.):
try to place in the help area of this question
for other place try:
BTW, all EM functions are listed here
try to place in the help area of this question
for other place try:
BTW, all EM functions are listed here
Benoît
EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
Last edit: 8 years 7 months ago by Ben_V.
The following user(s) said Thank You: DenisChenu, holch, first
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11658
- Thank you received: 2742
8 years 7 months ago #125896
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Letters counter
Hey Ben, thank you. This works great (only tried it with the "self" version).
@Helviobritto: No need to go for a plugin. LS has this onboard solution which works great and in real time.
@Helviobritto: No need to go for a plugin. LS has this onboard solution which works great and in real time.
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.
- Ben_V
- Offline
- Platinum Member
Less
More
- Posts: 1128
- Thank you received: 329
8 years 7 months ago #125907
by Ben_V
Benoît
EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
Replied by Ben_V on topic Letters counter
I suppose there is some way to change the number color when you are near or pass the limit, something like green -> orange -> red ...
Benoît
EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
The topic has been locked.
- Mazi
- Offline
- Official LimeSurvey Partner
4 years 10 months ago #185521
by Mazi
Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
Replied by Mazi on topic Letters counter
Using the integrated Limesurvey Expression manager functions is indeed the best approach. We have documented the full approach at this blog post: "
How to count the number of characters entered at a Limesurvey text question
". It also shows how to limit the number of characters and how to reference the character count at other questions.
Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11658
- Thank you received: 2742
4 years 10 months ago #185540
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Letters counter
@Mazi: Saw your post and tried your sample survey. Looks good. But I was able to send a text with 165 characters (according to your count). What happened?
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.
- Mazi
- Offline
- Official LimeSurvey Partner
4 years 10 months ago #185546
by Mazi
Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
Replied by Mazi on topic Letters counter
I also noticed that when entering some dummy characters. It tuend out that character like "<" had not been counted. Could it have been a similar case? If you just enter the same character 160 times it works fine.
Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11658
- Thank you received: 2742
4 years 10 months ago #185547
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Letters counter
I did not use any special characters, if I recall right (just have a look at the last result in your demo and you'll see my text).
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.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11658
- Thank you received: 2742
4 years 10 months ago #185548
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Letters counter
Here another test. I inserted this text until the text field wouldn't allow any further text.
Here what your demo shows me:
I copied and pasted the text into Word and it counted only 160 characters, just like Limesurvey did, but your function counted 165 characters...
This is a text with more than 160 characters. Let's see if it works now as expected. It should not be possible to insert more than 160 characters, but last time
Here what your demo shows me:
I copied and pasted the text into Word and it counted only 160 characters, just like Limesurvey did, but your function counted 165 characters...
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.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11658
- Thank you received: 2742
4 years 10 months ago #185549
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Letters counter
I think I found the vilain. It is the ' (apostrophe).
When you insert "Let" it counts 3 characters, just as it should. If you add the apostrophe and have something like "Let'" it jumps to 9, so the apostrophe counts as 6 characters. Let's is 10 characters.
So this would explain that your count counts 165 characters, when Limesurvey stops at 160 characters. So the error is in the function "strlen" somewhere I guess?
When you insert "Let" it counts 3 characters, just as it should. If you add the apostrophe and have something like "Let'" it jumps to 9, so the apostrophe counts as 6 characters. Let's is 10 characters.
So this would explain that your count counts 165 characters, when Limesurvey stops at 160 characters. So the error is in the function "strlen" somewhere I guess?
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.
- Mazi
- Offline
- Official LimeSurvey Partner
4 years 10 months ago #185551
by Mazi
Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
Replied by Mazi on topic Letters counter
Yes, I think so, but it is not really a bug: "strlen() returns the number of bytes rather than the number of characters in a string."
-> www.php.net/manual/en/function.strlen.php
-> www.php.net/manual/en/function.strlen.php
Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
The topic has been locked.