Fork me on GitHub

I have a style/pattern question for you this morning: I have several dropdowns, with data-driven names (ie. not known in advance) and contents - and each is associated with another dropdown, the contents of which should depend on the selection of its 'parent'. I set out to have the hx-target of the parent be the child to be repopulated, but I'm struggling to see how I can interpret the Post correctly; in particular, how to know which dropdown changed without splitting them all into separate forms, or doing some kind of ugly state-tracking, and I ultimately want all of their information to be submitted together. (hmm :thinking_face: can you nest forms; I suppose I should find that out to start with. I'm not a web-front-end-guy (I prefer game engines for UI))


for now I'm just recalculating the contents of all of them on-change 😕

Jacob O'Bryant16:10:44

the first thing that comes to mind is, I wonder if you can re-render all of the dropdowns together for simplicity? edit: I see that's what you're doing! if it's fairly straightforward and not computationally expensive to do so, that may not be a bad approach. though I think you can fairly easily have the htmx post include only data from the dropdown you've just changed. E.g. you can put :hx-post directory on the dropdown element, and then there might be a way to tell htmx to not include data from other elements in the form


hmm- it was directly in the dropdown, but I got the whole form in params. I'll read the htmx docs more thoroughly soon, but I'm on to my next headache: xtdb's text-search doesn't support wildcard-first matching :face_with_rolling_eyes:

Jacob O'Bryant17:10:09

yeah, finding out if there's a way to filter out the other form values would be the main thing. it looks like :hx-params might do that, except I can't tell for sure because the docs page for it is giving me an internal server error... (

Jacob O'Bryant17:10:35

haven't done any full-text search mint xtdb myself--but good luck :)

Jacob O'Bryant17:10:57

huh, looks like the internal server error is gone now. (maybe I caught it during a deploy or something...)


weird- it loads fine for me, and yes! this looks like what I would need. I kinda hate that i'm recalculating it all; it may get pretty costly, but it's an experiment that might turn into an admin interface of a product. not worth worrying about at the moment 🙂 thanks again! You've been super helpful, and if I ever make a dime from something I build with biff, you'll get a cent or two 🙂

Jacob O'Bryant17:10:51

haha excellent! I hope you make many dollars, tens of dollars even


(not a full tithe, but a nice bonus from the first influx) 😉

Jacob O'Bryant17:10:21

btw--there is another pattern I've used which may or may not work here. I have a dropdown, and the rest of the form's contents depend on the value of the dropdown. I render all the sections of the form on the initial page load, but only the "active" one is displayed, the rest are hidden. then I just stick a Hyperscript one-liner on the dropdown so that whenever the dropdown changes, the appropriate form section is shown. (the values of the dropdown correspond to the IDs of the sections).

Jacob O'Bryant17:10:55

then it's all client side too

Jacob O'Bryant17:10:23

I think the Hyperscript is something like show .section in #sections when its id is my value


hmmm- yeah, I like avoiding client-side, but that's pretty slick! thanks!

👌 1