Eddi
Eddi

Reputation: 95

How to get value of spectrum colorpicker value inside the texfield

Is it really possible to get the spectrum colorpicker inside a tesxtfield? I mean i want to be shown as a text exactly as the background color is ( rgb, or rgba ) .How can i achieve that,as i tried using another example from here and the official page of spectrum but it's not working. My example: http://jsfiddle.net/UkmXM/50/

<input type="text" value="" id="result"/>

<input type="text" id="backgroundColorPicker"/>

So i tried like this:

$(document).ready(function(){

    $('#backgroundColorPicker').spectrum({
        color: '#000',
        showAlpha: true,
        move: function(color){
            $('#result').css('background-color',color.toRgbString());
            $('#result').spectrum('get').toHexString();
        }
    });
});

and like this,but still is not working:

$(document).ready(function(){

    $('#backgroundColorPicker').spectrum({
        color: '#000',
        showAlpha: true,
        move: function(color){
            $('#result').css('background-color',color.toRgbString());  
            var value = $('#result').val();
        }
    });
});

Upvotes: 0

Views: 3141

Answers (1)

Eddi
Eddi

Reputation: 95

I answered my own question,this should work..http://jsfiddle.net/UkmXM/58/

$(document).ready(function(){
        $('#backgroundColorPicker').spectrum({
            color: '#000',
            showAlpha: true,showInput: true,

            move: function(color){
                $('#result').css('background-color',color.toRgbString());  
               $('#result').val(color.toRgbString());

            }

        });
    });

Upvotes: 2

Related Questions