work around for color picker
-
I’ve been doing a project where I need the user to specify various CSS parameters, including color. I really like the way Jazzy Forms works, but it does not have a color picker as a field choice. I’ve used a general color picker, and used it to implement a jazzy form element that is assigned the hex color code of the color chosen by the user with the color picker. I’ll describe what I did, so others may use it or possibly adapt it for other unsupported field types. Then I have a question.
I found a JS color picker called JSColor (see https://www.jscolor.com/). It is very easy to install and use. It has several modes of operation. Here is the HTML/JS code that I put into an Jazzy HTML field:
<label class="jzzf_number_label jzzf_element_label" for="jzzf_1_csscolor">define a color</label><input class="color {pickerPosition:'right'}" value="#D5FFD5" style="width:80px" onchange="document.getElementById('jzzf_1_csscolor').value = this.color">
In addition to the HTML field described above, I defined a standard Jazzy HIDDEN input field called csscolor. Here are some things to notice: (1) the styling for the JSColor field makes it look like a Jazzy form field. (2) When the JSColor field is defined via the color picker, the Jazzy field (csscolor) is assigned the value. (3) Jazzy uses jzzf_1_csscolor for this instance of the field. The number is an enumeration (1, 2, 3, …) for fields in multiple forms with the same name. You need to determine the ID assigned to the field you intend to fill.
———————————————
Here’s my question. This works very well, except for one Jazzy form option. I haven’t been able to figure out how to support the “Update output elements instantly” option. It would be nice to know how to augment the code to execute the equivalent of the update button to automatically post the form.
- The topic ‘work around for color picker’ is closed to new replies.