Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

157
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda