Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6815439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:48:26+00:00 2026-05-26T20:48:26+00:00

I am implementing a simple drop-down using hiccup: ;DATASET/CREATE (defn get-cols-nms [table] This function

  • 0

I am implementing a simple drop-down using hiccup:

;DATASET/CREATE
(defn get-cols-nms [table] 
      "This function gets the list of columns of a specific table".
  (do (db/cols-list table)))

(defpartial form-dataset [cols-list]
  (text-field "dataset_nm" "Input here dataset name")[:br]
  (drop-down "table" tables-n)
  (submit-button "Refresh")[:br]
  (mapcat #(vector (check-box %) % [:br]) cols-list) 
  )

(defpage "/dataset/create" []
  (common/layout
    (form-to [:post "/dataset/create"]
      (form-dataset (get-cols-nms (first tables-n))))))

(defpage [:post "/dataset/create"] {:as ks}
  (common/layout
    (let [table (ks :table)]
      (form-to [:post "/dataset/create"] 
    (form-dataset (get-cols-nms table))))))

What I need is to issue a post request (as I think this the only way to do it, but I am open to suggestions) when the drop-down is selected on a specific table (so that “get-cols-nms” gets called with the selected table). In this way, when a table of the database is selected in the drop-down, the table columns will be automatically showed.

So, ultimately, the main point is for me to understand better this function:

 (drop-down "table" tables-n) 

I think that to do what I want I need the tag to have an “onchange” attribute that calls a javascript function. But I don’t know: 1) if I can do this using the hiccup form-helper drop-down; 2) how can I issue (if this is the only solution, maybe there is an hiccup way?) a post request with javascript.

==EDIT==

Following the answer to this question, I rewrote the code above.It should be pretty straightforward. As I think there are not so many examples of hiccup out there, I will post my code here for reference.

Please, bear in mind that there is still a problem with this code: the drop-down won’t stay on the selected item, but it will return at the default. This is because it submits “onchange”. I still could not find a solution for that, maybe somebody could help…

;DATASET/CREATE
(defn get-cols-nms [table] 
  (do (db/cols-list table)))

(defpartial form-dataset [cols-list]
  (text-field "dataset_nm" "Input here dataset name")[:br]
  (assoc-in (drop-down "table" tables-n) [1 :onclick] "this.form.submit()")[:br]
  [:input {:type "submit" :value "Submit" :name "name"}][:br]
  (mapcat #(vector (check-box %) % [:br]) cols-list) 
  )

(defpage "/dataset/create" []
  (common/layout
    (form-to [:post "/dataset/create"]
      (form-dataset(get-cols-nms (first tables-n))))))

(defpage [:post "/dataset/create"] {:as ks}
  (common/layout
    (prn ks)
    (let [table (ks :table)]
      (form-to [:post "/dataset/create"] 
    (if (= (:name ks) nil)
    (form-dataset (get-cols-nms table))
    [:p "It works!"])))))
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T20:48:27+00:00Added an answer on May 26, 2026 at 8:48 pm

    hiccup.form-helpers/drop-down doesn’t directly support adding attributes to its select element, but it does guarantee there is a standard hiccup attribute map in its return value – meaning the attributes are a map at index 1 (the second element) of the returned vector.

    That means you can do something like

    (assoc-in (drop-down ....) [1 :onchange] "this.form.submit()")
    

    to generate a select tag with an onchange property.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I started down this path of implementing a simple search in an array for
I'm Implementing a simple web app using Django, I want to get user's location
I'm implementing a simple Graph library for my uni project and since this is
I am implementing a simple cache using LinkedHashMap based on the instructions found here
I'm implementing simple drag-and-drop functionality in my app, and I would like to know
I am implementing a simple DHT using the Chord protocol in Java. The details
I tried implementing a simple web service into an asp.net application using the tutorial
i am implementing the simple bubble sort algorithm using CUDA, and i have a
I am implementing a simple portal using jsp and struts, the user full fill
I'm trying to create JPA class implementing simple interface: public interface Task<T> { public

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.