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

314
Views
Tabla Flask en la que se puede hacer clic que almacena el valor en el que se hizo clic

Siguiendo algunos tutoriales de matraces, construí una tabla con filas en las que se puede hacer clic. Al hacer clic en cualquier valor de la columna de índice, se redirige al usuario a una nueva ruta con el nombre del valor de índice en el que se hizo clic, por ejemplo, @app.route(/1). Sin embargo, esto no es exactamente lo que quiero y estoy luchando para ajustar la aplicación a mis necesidades.

Me gustaría que el usuario se moviera a una ruta 'XYZ' sin importar el valor en el que se haya hecho clic. Luego, la ruta 'XYZ' debe imprimir/almacenar el valor del índice en el que hizo clic el usuario.

¿Cómo puedo cambiar el valor de anclaje HTML a estático y al mismo tiempo almacenar el valor en el que se hizo clic?

HTML

 {% extends "bootstrap/base.html" %} {% block content %} <head> <script type="text/javascript" src="{{ url_for('static', filename='js/click_table.js') }}"></script> </head> <table id="data" class="table table-striped"> <thead> <tr> <th>Index</th> <th>Playlist Name</th> <th>Playlist ID</th> </tr> </thead> <tbody> {% for index, row in playlists_df.iterrows() %} <tr> <td><a href="{{ row['index'] }}"> {{ row['index'] }} </a></td> <td>{{ row['name'] }}</td> <td>{{ row['id'] }}</td> </tr> {% endfor %} </tbody> </table> </form> {% endblock %}

JS

 $(document).ready(function() { $('#data tr').click(function() { var index = $(this).find("a").attr("href"); if(index) { window.location = index; } }); });

Parte de Python que estoy buscando:

 @app.route('/XYZ') def get_clicked_index_value(): # request index_value from JS return Index
about 4 years ago · Juan Pablo Isaza
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!