Welcome to the nuBuilder Forums!

Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.

Colour Picker

FBC-Tim
Posts: 25
Joined: Thu Jun 23, 2011 6:08 am

Colour Picker

Unread post by FBC-Tim »

Hi.

I'm new to nuBuilder and am very pleased with what I have seen so far.
And a great Australian product : )

Can someone please offer some example code or instructions on how to pick a colour in a control on an edit form.
Store the colour in a field of that record.
Then display individual rows on the browse from in the colour the user has selected.

Thank you for your help.
admin
Site Admin
Posts: 2825
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 30 times

Re: Colour Picker

Unread post by admin »

FBC-Tim,

I didn't quite understand your question.

Did you mean something like this..?
col.png
And can you explain again how you want to use the browser.

Steven
You do not have the required permissions to view the files attached to this post.
FBC-Tim
Posts: 25
Joined: Thu Jun 23, 2011 6:08 am

Re: Colour Picker

Unread post by FBC-Tim »

Thanks for your reply.

I want to be able to select a colour like the image you have posted (looks good).
Would be nice to have some type of dropdown that allows them to pick from about 10 suitable pre-set colours that will show ok on the background.
Then store the hex value of that colour in the database record.

When that record is shown in the list on the browse window I would like the text of each record to be in the colour the user selected for that record.
So the user can see the colours they have chosen to indicate different status types for each record.

Thank you for taking the time to consider my request :)
admin
Site Admin
Posts: 2825
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 30 times

Re: Colour Picker

Unread post by admin »

If you create a table called colour.
Add a a field called col_colour (as well as a Primary Key)

Create a form for it..
colour4.PNG
then put CONCAT("<span style='background-color:",col_colour,"'>",col_colour,"</span>")
in the display part of for the browse ..
colour3.PNG
You should get this..
colour.PNG
I hope this helps.

Steven
You do not have the required permissions to view the files attached to this post.
FBC-Tim
Posts: 25
Joined: Thu Jun 23, 2011 6:08 am

Re: Colour Picker

Unread post by FBC-Tim »

Thanks a lot.
Got that to work nicely : )

Any way to make the full width of the field coloured on the browse screen?
Tried to use a div with background-color set instead of the style but the resulting div was squashed flat and did not show the text.
admin
Site Admin
Posts: 2825
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 30 times

Re: Colour Picker

Unread post by admin »

Try..

CONCAT("<span style='width:1000;background-color:",col_colour,"'>",col_colour,"</span>")

(or whatever)

this is HTML style sheet stuff, bot really nuBuilder.

Steven
FBC-Tim
Posts: 25
Joined: Thu Jun 23, 2011 6:08 am

Re: Colour Picker

Unread post by FBC-Tim »

My colour lookup looks like the image I have attached below, thanks for your help on this, it looks great : )
MyColourLookup.PNG
You may need to clarify one more thing for me please.
I have found that when I try and use the PRINT button to print a browse list that has the CONCAT(...) in the Display field it throws an error as shown below.

How is it possible to print when the Display field has been enhanced to show the colour?
An error has occurred while running this query. Please contact technical support and quote error reference: fad1fd7.

The following information is only provided for users logged on as globeadmin.

SQL

SELECT CONCAT('<span style='width:150;background-color:',colour_data,''>',colour_name,'</span>') FROM colour ORDER BY colour_name

Error

1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'width:150;background-color:',colour_data,''>',colour_name,'</span>') FROM colour' at line 1
You do not have the required permissions to view the files attached to this post.
admin
Site Admin
Posts: 2825
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 30 times

Re: Colour Picker

Unread post by admin »

FBC-Tim,

I don't think your single quotes and double quote match up correctly.

Steven
FBC-Tim
Posts: 25
Joined: Thu Jun 23, 2011 6:08 am

Re: Colour Picker

Unread post by FBC-Tim »

admin wrote:I don't think your single quotes and double quote match up correctly.
Steven
I agree.

In the Display part of the browse i have this string:
(I have highlighted the double quotes in red and left the single quotes balck)
CONCAT("<span style='width:150;background-color:",colour_data,"'>",colour_name,"</span>")

In the error screen shown when I press the PRINT button:
(All the double quotes have been translated to single quotes)
SELECT CONCAT('<span style='width:150;background-color:',colour_data,''>',colour_name,'</span>') FROM colour ORDER BY colour_name

This is also shown further down the page - it may help as it clearly shows what is happening to the single and double quotes.

Code: Select all

[tra_message] => $TRAP_sql='SELECT CONCAT(\'<span style=\'width:150;background-color:\',colour_data,\'\'>\',colour_name,\'</span>\') FROM colour ORDER BY colour_name'; $TRAP_b4sql=''; $TRAP_col='150,c,Colour,~'; $TRAP_cnt='1'; $TRAP_tmp='___nu14e0a69f1bb4f7___';
This SQL must be working ok to display the colours on the browse screen but when PRINT is pressed the double quotes all get converted to single quotes and the SQL falls over.
Maybe I have a setting wrong in my PHP or something like that?

Is there a way to have a different Display string for the Browse? One for on screen, with the colours, and one for printing, with regular text only?
admin
Site Admin
Posts: 2825
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 30 times

Re: Colour Picker

Unread post by admin »

It seems you have found a bug!

You'll have to work around it til our next release.
Sorry about that


Steven
Post Reply