How to color picker (advice required)

23 views
Skip to first unread message

Alan Etkin

unread,
Jan 28, 2026, 5:04:02 PM (14 days ago) Jan 28
to py4web
Does anyone has embedded a color picker widget in a py4web form? Any hints?

Thanks

Alan

Christian Varas

unread,
Jan 28, 2026, 5:59:26 PM (14 days ago) Jan 28
to Alan Etkin, py4web

Hello, I usually don’t use a widget for this. I use JavaScript.

First, you need to know the ID of the input in your form. To do this, first render the form normally and then use the developer tools to inspect the HTML and find the ID of the input that you want to turn into a color picker. After that, using JavaScript and the ID, you can convert the input into a color picker.


example

include 'layout.html'

<h2>Example Form</h2>

[[=form]]

<script>
document.addEventListener("DOMContentLoaded", function () {
// Locate the input by its id
const colorInput = document.getElementById("favoriteColor");

// Convert it into a color picker
colorInput.type = "color";

// Optional default value
colorInput.value = "#00ff00";
});
</script>



greetings 


--
You received this message because you are subscribed to the Google Groups "py4web" group.
To unsubscribe from this group and stop receiving emails from it, send an email to py4web+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/py4web/10700b59-c1c8-42ab-b793-78e44fd74b49n%40googlegroups.com.

Alan Etkin

unread,
Jan 29, 2026, 5:38:49 AM (13 days ago) Jan 29
to py4web
Great! Thanks for the example. Maybe this can be converted to a custom py4web widget

Alan
Reply all
Reply to author
Forward
0 new messages