PDA

View Full Version : [SOLVED]Textfield value to color



Sniper[tb]
16 Jul 2010, 12:47 AM
Hi there!

Is there any possibility to write some hex-color-code into an textfield which process to another field where a color gets create from the text?
For example: I write down FFFFFF into the textfield, the small quadratic field right from the textfield changes it's color to white.
Do you have any idea to realize that?

Greetings, Sniper

Sniper[tb]
16 Jul 2010, 4:39 AM
Work is done:



xtype : 'compositefield'
,fieldLabel : 'Colour'
,items :[{
id : 'uc-admin-colorselect'
,xtype : 'textfield'
,value : ''
,emptyText : 'Enter HEX-Color-Code'
,maskRe : /[a-f0-9]/i
,minLength : 3
,maxLength : 6
,flex : 9
,enableKeyEvents : true
,listeners : {
keyup : function(field, event) {
var value = field.getValue();
if( value === '' ) value = 'fff';
if( value.length === 3 || value.length === 6 ) {
Ext.get('colorset-preview').applyStyles('background-color: #'+ value);
}
}
}
},{
id : 'uc-admin-colorselect-display'
,xtype : 'displayfield'
,html : '<div id="colorset-preview" style="background-color: #fff; height: 19px; border: 1px solid #B5B8C8;">&nbsp;</div>'
,flex : 1
}]
That is the image now: 21485

Greetings, Sniper