I am using jQuery Colorpicker for some reasons i need to set change the values of the fields directly from javascript.

I found this function HERE in the plug in website


But no luck. Have you experienced something like this. What is the way to do this? Is there any other modules i can use ?

1 Answer 1


You are setting 'input' which references any input on the site. Use the #id of the input field so that the input field you are targeting is explicit. To find this use firebug, chrome developer tools etc.

Also use Drupal.behaviors to load events where possible. Standard jQuery events do work but you get them all in the one place and clearly namespaced https://stackoverflow.com/questions/3941426/drupal-behaviours.

The code with the specific #id and wrapped in behaviors starts to look like the following, with the field changed to your color field:

(function($) {
    Drupal.behaviors.myModule = {
        attach: function(context, settings) {
            $('#edit-field-meeting-date-und-0-value-datepicker-popup-0', context).change(function() {
                // update code here

                $('#edit-field-submission-cutoff-und-0-value-datepicker-popup-0', context).val(formattedMonth);

Finally, always inspect the code in the browser because javascript caching/optimization may be on. Check that there are no javascript errors in the browser console.

  • I will try this and let you know the result..
    – niksmac
    Commented Mar 21, 2013 at 17:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.