0

I have a table that gets all the data from a MySql database and displays it, and was wondering how to change the table cell to a text area on click and also display 2 buttons, a save button and a cancel button.

The save button would then send the changed information along with the id of the row to another page, that has an sql query to update the database with the new information.

I have seen this but am not sure as to how to change it so that it has a cancel and save button instead, where clicking outside would be the same as cancel. My PHP Code for displaying the Table Cell in the table:

if (empty($row{Additional_Info})) {
     $additional = 'No Additional Info';
}
else {
     $additional = $row{'Additional_Info'};
}
echo '<td class="additional">' . $additional . "</td>";

Any help is appreciated.

Thank You

Community
  • 1
  • 1
dhruveonmars
  • 409
  • 1
  • 11
  • 24

1 Answers1

0

use ajax on click of the button. you need to post more of your HTML table for to give you better answers

Akhil Sidharth
  • 746
  • 1
  • 6
  • 16
  • I think clicking the save button would run a function which would then pass the data to another page where my sql statement would update the database. I am just having trouble changing the table cell to a text area, a save button and a cancel button. So what I need help with is converting the table cell to a text area and 2 buttons. – dhruveonmars Feb 13 '14 at 10:21
  • the buttony you can create with jQeury and [https://api.jquery.com/append/] .append() function. – GoE Feb 13 '14 at 10:26
  • usually what i do is create a div with the id in the location of the table where you want to change to text area. then use this id in Ajax to change the cell which you receive from the other page as ajax result – Akhil Sidharth Feb 13 '14 at 10:27
  • @GoE I tried adding `$( "#gird_edit" ).append( "" );` to the function in the link, but it doesn't allow me to click on the button whilst i have changed it to a text area. – dhruveonmars Feb 13 '14 at 10:34
  • @AkhilSidharth How would I go about doing that? – dhruveonmars Feb 13 '14 at 10:35