Add Color Picker in question type

More
2 months 4 days ago #196112 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.

Please Log in to join the conversation.

LimeSurvey Partners
More
2 months 4 days ago #196136 by tpartner
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.
Official LimeSurvey Partner - partnersurveys.com

Please Log in to join the conversation.

More
2 months 2 days ago #196210 by egroeg
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


Attachments:

Please Log in to join the conversation.

More
2 months 2 days ago #196219 by tpartner
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.
Official LimeSurvey Partner - partnersurveys.com

Please Log in to join the conversation.

More
2 months 2 days ago #196235 by egroeg
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
Attachments:

Please Log in to join the conversation.

More
2 months 2 days ago #196253 by DenisChenu
With a short text question type


Try this in script part
$("#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 .
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

More
2 months 2 days ago - 2 months 2 days ago #196275 by tpartner
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.
Official LimeSurvey Partner - partnersurveys.com
Last edit: 2 months 2 days ago by tpartner.

Please Log in to join the conversation.

More
2 months 2 days ago - 2 months 2 days ago #196283 by DenisChenu

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
<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 .
An error happen ? Before make a new topic : remind the Debug mode .
Attachments:
Last edit: 2 months 2 days ago by DenisChenu.

Please Log in to join the conversation.

More
2 months 2 days ago #196287 by egroeg
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:
#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!
.
.
.
.

.
Attachments:

Please Log in to join the conversation.

More
2 months 2 days ago #196293 by tpartner

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.
Official LimeSurvey Partner - partnersurveys.com

Please Log in to join the conversation.

More
2 months 2 days ago #196305 by DenisChenu

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 .
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now