I have a Clojure table in Hiccup that is populated from a database. In one column I have status which is set from the database.
What I want to do is be able to click on this value, and have a dropdown menu appear where you can pick a new status from the dropdown menu.
I am confused on how to do this. I have tried using a form with a placeholder where the value comes from the database but when I click on the status in the browser, I have to type instead of having a dropdown. How do I get the dropdown?
(defn row-data [data]
(for [x data]
(let [[entity-id id date text status] job]
(hiccup/html
[:tr
[:td date]
[:td id]
[:td text]
[:form {:method :post}
[:td
[:input {:type :text :placeholder status}]]]
]))))
Any help would be much appreciated. Thanks
If I understood your task, you don't need to use [:input]
with {:type :text}
, if you don't want to type into field.
Try using (drop-down attr-map? name options)
instead.
https://weavejester.github.io/hiccup/hiccup.form.html
Also you can try to make your form look like this:
[:form {:action "/handler_name"}
[:td
[:select {:name (str "update_status_" id)}
[:option {:value "1"} "1"]
[:option {:value "2"} "2"]
[:option {:value "3"} "3"]
[:option {:value "4"} "4"]]
[:input {:type "submit"} "Update"]]]