I have a problem:
I have a textarea on my page that looks like this:
<textarea id='redactor_content' name='redactor_content' style='width: 720px; height: 320px;'>$news[3]</textarea>
Where $news[3] is a php variable that I get from MySQL. redactor_content is a WYSIWYG editor where I edit the content of $news[3]. After the content is edited, I want to pass it to mysql to update the table with the following JavaScript:
function update_news(n_id) {
var title = $('#title').val();
var news_body = $('#redactor_content').val();
alert(news_body);
$.post(
"update.php",
{n_id: n_id, title: title, body: news_body},
"html"
)};
There are 2 more variables in JS which are n_id and title. Both are working OK. But when the alert pops up with the news_body variable I see the old version of textarea (which was initially in the $news[3] variable), not the new, updated one.
I’m stuck guys. Any help is appreciated!
most of the wysiwyg editors create a new separate section on the page (an iframe usually) that overlays the textarea they’re replacing. You’d need to tell the editor to copy the data in the “fancy” graphical version back to the original form fields so your JS can get the updated version. or figure out how/where the editor is storing the overlayed version so you can grab it from there.