Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

156
Views
How to get POST form data that have dynamic IDs?

I have checkboxes inside a form. These checkboxes are a list of persons dynamically created since this list depends on who is logged in. Like, for a supervisor view, it will only list your subordinates.

I'm not sure if I'm missing something but the docs and other answers in SO are all saying that you have to have the id of the input in order to retrieve the form data but in my case, I used the person's ID in the list to come up with the name of the checkbox element. So my checkbox names are like input-{{person_id}}

Now in the post method, I'm not sure how to retrieve the checkboxes in the form. Tried using self.__dict__ but I can't seem to find anything that I can use

link1 - this specifies the name

link2 - this also says that the ID should be pre-determined

link3 - docs also say that if the parameter is not included, an empty list would returned

Maybe there is a workaround where I just get all the elements in the form and make them seen in tornado? Using javascript maybe?

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

I'm mistaken, it seems that if you use the same name for a checkbox element for all the dynamic checkboxes you create, then when you submit it to the tornado web handler, it will get the values of all those checkboxes that have that name.

the values are retrieved by using the get_arguments

about 4 years ago · Juan Pablo Isaza Report

0

Is this how you mean?

HTML

<form>
  <input type="checkbox" id="box1" name="Name1" checked>
  <label for="box1">Name 1</label>
  <input type="checkbox" id="box2" name="Name2">
  <label for="box2">Name 2</label>
</form>

jQuery

$("form input[type='checkbox']").each(function() {
  console.log($(this).attr('name'))
})

Output

"Name1"
"Name2"
about 4 years ago · Juan Pablo Isaza Report

0

You can loop through the request.body_arguments attribute; it's dict which maps arguments names to lists of values (to support multiple values for individual names).

class MyHandler(tornado.web.RequestHandler):

    def post(self):
        for key, value in self.request.body_arguments.items():
            print(f"key {key} has value: {value}")
        ...

There are also arguments (holds both query and body args) and query_arguments (holds only query args) attributes; you can check the docs here.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!