To explain what I’m asking let me explain the situation:
I have a webpage, a.html, where I display the content of a database. To do so I have a route /view_a that performs a query on the database that goes something like “select … where id_table = …”.
Now, the first time I call /view_a I do so through a form-post where the id_table is one of the variables inside request.form, but I would like to also let the user modify the content I’m displaying. Meaning, on a.html there is a button “update” inside another form that should update the database via a specific route /update_a. My question is how can I have access inside said route to “id_table”.
I have come up with two solutions, but both don’t seem to be optimal:
- inside “/view_a” I also add to the session a value where I store the id, something like “session[“current_table”]” equals to “id_table”. The problem here is that the user could request to view multiple tables at the same time in different web tabs, basically current_table would get overwritten. Making it a list isn’t also a solution because how would I then know which index is the one I want?
- I attach the “id_table” to the value of the “update” button. It works but it seems like a “patch” and not a proper common solution
Is there a way to achieve what I’m looking for?
Korr4K is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.