Text box and dropdown in DataTable to trigger SQL query

Text box and dropdown in DataTable to trigger SQL query

rvossrvoss Posts: 1Questions: 0Answers: 0
edited February 2022 in Free community support

Description of problem:
I am new to DataTables and JavaScript but have managed to get a basic configuration running. I have created a dynamic HTML page with PHP, whereby the data for the DataTable is pulled from a MySQL database. The PHP script then writes the HTML code of the table. Thanks to DataTables my table is now also searchable and sortable. That all works fine.

Next, I would like to add 2 columns to my DataTable:

1: A column which contains a dropdown menu control in each row. The valid choices in the dropdown are the same categories (“high”, “medium”and “low”) for each row.

When the user changes the selection in the dropdown menu, I would like this to trigger an UPDATE SQL query to update the value of the category based on the user’s choice in the dropdown. This should happen in the background, without a reload of the page.

2: A column which contains an empty text box control in each row. This is for the user to add some comments on that row.

When the user has updated a text box and the cursor has left the text box, I would like this to trigger an UPDATE SQL query in the background which updates the comments field in my database for that row.

Would anyone be able to give me some pointers on how I could achieve this? Thank you very much for your help!

Replies

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    You would need to use something like Editor to get that data sent back from the client to the server for the update. This example demonstrates for to do that within Editor, with a JOIN table,

    Colin

Sign In or Register to comment.