Shorty
Shorty

Reputation: 23

How to send contenteditable value in td with php

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??

Upvotes: 0

Views: 1724

Answers (2)

YakovL
YakovL

Reputation: 8316

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".

Upvotes: 0

Giedrius
Giedrius

Reputation: 1390

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.

Upvotes: 1

Related Questions