Board Logo

Omitting Pound (#) Sign
ekautz - 7/31/2003 at 06:02 PM

Excellent color picker!

Is there already a way to toggle the pound sign (#) on and off for the popup and final text field color value? I quickly scanned your code but didn't see anything obvious so...

To picker.js I added the variables

var PUpsign;
var TFpsign;

and added two parameters and two lines to this function

function TCPopup(field, palette, ppsign, tpsign) {
PUpsign = !ppsign || ppsign == 0? '' : '#';
TFpsign = !tpsign || tpsign == 0? '' : '#';

and modified

function TCSelect(c) {
this.field.value = '#' + c.toUpperCase();

to

function TCSelect(c) {
this.field.value = TFpsign + c.toUpperCase();

and

function TCPaint(c, b_noPref) {
c = (b_noPref ? '' : '#') + c.toUpperCase();

to

function TCPaint(c, b_noPref) {
c = (b_noPref ? '' : PUpsign) + c.toUpperCase();

then I modified the main function call by adding the two new parameters

<a href="javascript:TCP.popup(document.forms['request2'].elements['color'],0,1,0)">

where 0 = omitting # and > 0 = adding #

The first parameter is to toggle the # sign for the popup and the second parameter is to toggle the text field value

Now I can easily save just the number values to my database field when needed without the #

I tried to use

PUpsign = !ppsign || ppsign >= 1? '#' : '';
TFpsign = !tpsign || tpsign >= 1? '# : '';

so if the parameters where not used then it would default to # but I couldn't get that work??? always picked up the #


Softcomplex: http://www.softcomplex.com/
Back to forum: http://www.softcomplex.com/forum/