0

I have the following code in my page:

 echo "<td style='border-bottom:1px solid #FFA500;' contenteditable='true'>".$result['body']."</td>";

And I want to send the edited content to mysql_query.

do I simply have to add id to <td> and use ajax??

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
Shorty
  • 15
  • 6

2 Answers2

1

EDIT: Please check the following question for more information, references and helpful answers: How to save and retrieve contenteditable data


Yes, you have to use AJAX to store the edited content, or use a script that generates (hidden) input fields and submits a form with the edited values.

Ready more about contenteditable here (particularly 'Storing the changes'): http://html5doctor.com/the-contenteditable-attribute/#storing-changes

It gives you a JS Bin code snippet where it shows an example how you could send the data to the server using jQuery's $.ajax. It does it on keydown event however, and to save requests, I would suggest doing it on blur.

Community
  • 1
  • 1
Giedrius
  • 1,370
  • 3
  • 14
  • 37
0

Yes, you should use Ajax. If you want to "live update" it, use input event to listen when the contenteditable changes; or create a button if you want to save your value "when they're done".

Graham
  • 7,431
  • 18
  • 59
  • 84
YakovL
  • 7,557
  • 12
  • 62
  • 102