Welcome to the LimeSurvey Community Forum

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

buttons to increase/deacrease numerical input (spinners)

  • KompetenzZ
  • KompetenzZ's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
5 years 3 months ago #177576 by KompetenzZ
Hi,

I found this jquery widget with buttons to increase/decrease the current value: jqueryui.com/spinner/

I tried to integrate this widget in my multiple numerical input subquestions but I don't know how. When I copy the jquery code to the subquestion source of the multiple numeric input question, it creates a new input field (and this new input field does not have the increase/decrease buttons).

Can you give me please a hint how to integrate the increase/decrease buttons in the existing limesurvey input field?

See screenshot:

Cheers kompetenzz
Attachments:
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 3 months ago - 5 years 3 months ago #177588 by DenisChenu
If you always use . for numerci separator, best is to create a views/survey/questions/answer/numerical/answer.twig in your theme copy pasted the original one but
replace C.Html.textField by C.Html.numberField

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Last edit: 5 years 3 months ago by DenisChenu.
The topic has been locked.
  • KompetenzZ
  • KompetenzZ's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
5 years 3 months ago #177663 by KompetenzZ
Hi,

I took the "answer.twig" file from there:

/home/[servername]/www/application/views/survey/questions/answer/numerical/answer.twig

and then I navigated to:

/home/[servername]/www/upload/themes/survey/[yourTemplateName]/views

and created there the sub folders:

/survey/questions/answer/

and pasted there the file "answer.twig" and changed in the file "C.Html.textField" to "C.Html.numberField".


What else do I have to do for these increase/decrease buttons? It seems that nothing has changed.

Cheers kompetenzz
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 3 months ago #177667 by tpartner
You should be in /upload/themes/question/, not /survey/.

Have a look at some of the question themes here (or in Denis' repositories) to see the file structure - github.com/tpartner

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 3 months ago - 5 years 3 months ago #177669 by DenisChenu

tpartner wrote: You should be in /upload/themes/question/, not /survey/.

Have a look at some of the question themes here (or in Denis' repositories) to see the file structure - github.com/tpartner

No, no,

I talk for : replacing Core twig file ,

see gitlab.com/SondagesPro/SurveyThemes/acce...ons/answer/numerical

Then to ./upload/yoursurveytheme/views/survey/questions/answer/numerical/answer.twig

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Last edit: 5 years 3 months ago by DenisChenu. Reason: complete dir name
The topic has been locked.
  • KompetenzZ
  • KompetenzZ's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
5 years 3 months ago #177677 by KompetenzZ
Hi,


I took the "answer.twig" file from the link of your previous post and changed the "C.Html.textField" to "C.Html.numberField".

Then I navigated to:

/home/[servername]/www/upload/themes/survey/[yourTemplateName]/views

and created there the sub folders:

/survey/questions/answer/numerical

and placed the the new "answer.twig" file here.


Is this correct? It seems that nothing has changed. Attached is my theme.

File Attachment:

File Name: extends1_b...2-02.zip
File Size:190 KB

Cheers kompetenzz
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 3 months ago - 5 years 3 months ago #177700 by DenisChenu
I don't say to take the one for accessible_vanilla

copy pasted the original one but


But seems ls didn't accept numberfield, is just a little more long

Work on all good browser …

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Last edit: 5 years 3 months ago by DenisChenu.
The topic has been locked.
  • KompetenzZ
  • KompetenzZ's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
5 years 3 months ago - 5 years 3 months ago #177713 by KompetenzZ
Well, thank you very much for adding the twig files for both questions "numerical input" and "multiple numerical input". That was a great help. As I have several multiple numerical questions, these are handy for persons who are less familiar with the keyboard. However, is there a way to increase the size of these increase/decrease buttons without increasing the size of the whole textbox? Because the buttons represent very small targets.
And I noticed that these buttons do not show on my smartphone (with the current firefox), but that's a minor thing.

Cheers kompetenzz
Last edit: 5 years 3 months ago by KompetenzZ.
The topic has been locked.
  • KompetenzZ
  • KompetenzZ's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
5 years 3 months ago - 5 years 3 months ago #177715 by KompetenzZ
P.S.: Sorry I just want to mention another issue: When the value in the input field does not comply with the max and the min value (which can be set in the input options of the (multiple) numerical question) then the whole inputs of the input fields are made empty again. So, when the answer does not comply with the min/max, the fields are empty again (after clicking "Next"). This is not the case, when I do not insert the twig files. See screenshots.

Screenshot without increase/decrease buttons (normal, tip is red):



Screenshot with increase/decrease buttons (empty and tip is not red)

Cheers kompetenzz
Last edit: 5 years 3 months ago by KompetenzZ.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 3 months ago - 5 years 3 months ago #177728 by DenisChenu
Here, i just move from text input to number input : developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number

Browser must do the job : I think your firefox is outdated here.

But : seems there are an issue about javascript control : this must be rewritten differently … sorry :/

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Last edit: 5 years 3 months ago by DenisChenu.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 3 months ago #177729 by DenisChenu
OK,

A fixed template with the script inside custom.js

File Attachment:

File Name: extends1_b...fix2.zip
File Size:191 KB


Remind : it's only usage of developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number

Nothing less, nothing more.

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
  • KompetenzZ
  • KompetenzZ's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
5 years 3 months ago - 5 years 3 months ago #177827 by KompetenzZ
Thank you very much for all the help. Yes, firefox on smartphone works perfectly, I just had to realize that mobile browsers show a special keyboard and no increase/decrease buttons.

The link you provided is very useful.
If someone else ever needs this: After the part:
Code:
<input type="number"

in the twig files some settings can be added, especially a minimum and maximum can be set, so that the spinners cannot operate to undesired number ranges. Also a placeholder "0" at the begin can be displayed:
Code:
<input type="number"  min="0" max="100" placeholder="0"

Cheers kompetenzz
Last edit: 5 years 3 months ago by KompetenzZ.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose