Welcome to the LimeSurvey Community Forum

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

Add Color Picker in question type

  • egroeg
  • egroeg's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 3 weeks ago #196112 by egroeg
Add Color Picker in question type was created by egroeg
Hi all,

for a survey I'd like to add a color picker to a few questions, is there a way to do that?

I thought I could use the script field, but I can't find any hints on how to use it.
e.g. with this... <input type="color" id="favcolor" name="favcolor" value="#ff0000">


thanks for any help.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 3 weeks ago #196136 by tpartner
Replied by tpartner on topic Add Color Picker in question type
What is the use-case? The <input type="color" /> element does not work in IE.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • egroeg
  • egroeg's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 3 weeks ago #196210 by egroeg
Replied by egroeg on topic Add Color Picker in question type
In a survey we would like to get user feedback on a "prefered color".
I was hoping to be able to use a color picker and store the hex value as the answer. ( The top one here would be nice.)

But apparently I don't quite understand how to use the script field when setting up a question. No matter what I put in there, it always defaults to "javascript" and in any case nothing is shown when checking the question preview.

Obviously I am not a programmer. ;) But I could also find no real explaination in the LimeSurvey docs on how to use that script editor.

thanks,
george


The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 3 weeks ago #196219 by tpartner
Replied by tpartner on topic Add Color Picker in question type
I see no "top one" that is available for download.

I think if you want this to be compatible with all modern browsers, you will need to find and install a JavaScript plugin/library for the colour picker.

Regarding the editor, maybe you don't have the correct permissions to insert JavaScript.

- manual.limesurvey.org/Global_settings#Security

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • egroeg
  • egroeg's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 3 weeks ago #196235 by egroeg
Replied by egroeg on topic Add Color Picker in question type
hi tony,

sorry, was talking about the one highlighted below.

I get the HTML5 color picker (see img "Or use HTML5:") to show up in my question area. (last two images) but I don't have the slightest idea on how to get the "selected" color across into the text field.

well, but at least people can pick a color and punch in the RGB/hex values in regular numeric input fields. close enough.



thanks anyway. don't want to waste your time. this is obviously out of my league. :whistle:

cheers,
george
.
.
.
.
.


Color Pickers ( www.w3schools.com/colors/colors_picker.asp )




Question in source mode



Question preview
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 3 weeks ago #196253 by DenisChenu
Replied by DenisChenu on topic Add Color Picker in question type
With a short text question type


Try this in script part
Code:
$("#answer{SGQ}").attr('type','color');

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.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 3 weeks ago - 4 years 3 weeks ago #196275 by tpartner
Replied by tpartner on topic Add Color Picker in question type
That input type is buggy in IE (at least in my tests).

Additionally it looks like George doesn't have permissions to insert JS or inputs.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 4 years 3 weeks ago by tpartner.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 3 weeks ago - 4 years 3 weeks ago #196283 by DenisChenu
Replied by DenisChenu on topic Add Color Picker in question type

tpartner wrote:
Additionally it looks like George doesn't have permissions to insert JS or inputs.

Oh ... unsure : i check this mroning with github : seems broken ...

@egroeg

Can you test update question text in source mode and add this
Code:
<script>
 
$(function() {
  $("#answer{SGQ}").attr('type','color');
   alert("Xss seems disable");
});
</script>

And look again in source mode if you still have it :)


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: 4 years 3 weeks ago by DenisChenu.
The topic has been locked.
  • egroeg
  • egroeg's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 2 weeks ago #196287 by egroeg
Replied by egroeg on topic Add Color Picker in question type
great, that worked!! :woohoo:

i now have that simple color picker as an answer field.

still no idea, what you did there. know nothing about JS or jquery. am more of a lego-coding kind of guy. just playing around with bits and pieces of code, whithout knowing what i do, most of the time. sorry. x)

1.) from what i understand, this is using jquery? ( api.jquery.com/attr/#attr-attributeName-value )
couldn't find anything on the synthax used here:
Code:
#answer{SGQ}
could you possibly point me to a part of the manual?

2.) I guess it is kind of chaining attributes as I would do in Excel, right? just asking because i thought i could use TGO/LGO and "Long Text" as the input field, to get a larger color picker.

3.) also, the default color is black. how would i set a different value?


but again, this is already awesome. thanks for your help!
.
.
.
.

.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 2 weeks ago #196293 by tpartner
Replied by tpartner on topic Add Color Picker in question type

i now have that simple color picker as an answer field.

That will not work in Internet Explorer.

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
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 2 weeks ago #196305 by DenisChenu
Replied by DenisChenu on topic Add Color Picker in question type

tpartner wrote:

i now have that simple color picker as an answer field.

That will not work in Internet Explorer.

I know, starting point :)

And here : lack of em script (on('change'))

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.

Lime-years ahead

Online-surveys for every purse and purpose