Color Picker / Posts /

How to get value of Chosen color?

18
Hi, there. I have installed your Custom Color picker and set it up like your demo but I have a question. I need users to choose the color and need to capture the color title as a value in my shopping cart. I am not sure how to use the event handler to do this. Can you show me a way how to do this?
Thank you.
Martin Tan  11 years ago   viewed: 10928    

2 Answers

1
Our colour picker demo page has given you the following sample code:

function OnCustomColorChanged(selectedColor, selectedColorTitle, colorPickerIndex) {
        //here we use only one of the passed in parameters: selectedColorTitle
        var tShirt = document.getElementById("tShirt");
        tShirt.src = "colorpicker/img/" + selectedColorTitle.replace(" ", "-") + ".jpg";
};

You should assign the second parameter value to a variable and use it for your further processing.
a a a

Milo   11 years ago
-3
Hi Milo,
Thanks but I am not a coder, so I am not understanding any of this ;(  Can i use the code this way?
<script type="text/javascript">
    function OnCustomColorChanged(selectedColor, selectedColorTitle, colorPickerIndex) {
        //here we use only one of the passed in parameters: selectedColorTitle
        var PaintCode = document.getElementById("PaintCode");
        PaintCode.src = selectedColorTitle;
    };
</script>

But I still don't know where to insert the event handler.
Martin Tan
  11 years ago

   

Your name*
Password
(Optional. Used to modify this post afterwords)
+ =  

Ask your Own Question

  • If your question is related to the topic of this post, you can post your question to this page by clicking the "Post a reply" button at left;

  • When you want to start a new page for your question: