Board Logo

Little Color Picker update
mrtickles - 6/27/2003 at 02:48 PM

Hi,

I have been playing with the color picker (which works very well btw) but needed a slight modification.
Basically the parent page had a td containing a block with text which needed to be updated once a color was selected. I spent a fair bit of time playing and am not a native javascript coder so the syntax could probably be done far better. If you update the TCSelect function with the one below and then in your html page modify the following links (I only added the 2 extra options, the first being the id tag of the td/div you want to update and the second you either specify 'font' or 'bg' to update the relevant style) then you can have the parent page physically displaying the color choice.

#######
modified html llink

<a href="javascript:TCP.popup(document.forms['tcp_test'].elements['highbgcolor'],'', document.getElementById('rollover'), 'bg')">

########
update TCSelect function

function TCSelect(c) {
this.field.value = '#' + c.toUpperCase();
if(this.changeType == 'font') {
// change font
this.parent.style.color = this.field.value;
} else {
// background
this.parent.style.background = this.field.value;
}
this.win.close();
}

########
change first few lines of TCPopup

function TCPopup(field, palette, parent, changeType) {
this.field = field;
this.parent = parent;
this.changeType = changeType;

#######
finito

I tested it on IE6 and NS7 and both were fine. Use if you like :o)
Simon


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