无法获取更新的textarea值 [英] Unable to get Updated textarea Value

查看:287
本文介绍了无法获取更新的textarea值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有问题:

我的页面上有一个文本区域,如下所示:

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>

其中$news[3]是我从MySQL获得的php变量. redactor_content是一个所见即所得的编辑器,我在其中编辑$news[3]的内容.内容编辑后,我想将其传递给mysql以使用以下JavaScript更新表:

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"
    )};

JS中还有两个变量,分别是n_idtitle.两者都工作正常.但是,当警报以news_body变量弹出时,我看到的是旧版本的textarea(最初位于$ news [3]变量中),而不是新的更新版本.

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!

推荐答案

大多数所见即所得的编辑器在页面上创建一个新的单独部分(通常为iframe),该部分覆盖了要替换的文本区域.您需要告诉编辑器将精美"图形版本中的数据复制回原始表单字段,以便您的JS可以获取更新的版本.或弄清楚编辑器如何/在何处存储叠加版本,以便您可以从那里获取它.

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.

这篇关于无法获取更新的textarea值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆