表单发布后,您如何从Tinymce获取内容? [英] How do you get the content from Tinymce when the form is posted?
问题描述
<!DOCTYPE html PUBLIC - // W3C // DTD XHTML 1.0 Transitional // ENhttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
< html xmlns =http://www.w3.org/1999/xhtml>
< head>
< meta http-equiv =Content-Typecontent =text / html; charset = utf-8/>
< title>צורכתבה< / title>
< script type =text / javascriptsrc =tiny_mce / jquery.js>< / script>
< script type =text / javascriptsrc =tiny_mce / tiny_mce.js>< / script>
< script type =text / javascript>
tinyMCE.init({
模式:textareas,
主题:高级,
theme_advanced_toolbar_location:top,
height: 1000px,
width:800px,
editor_selector:mceEditor
});
tinyMCE.activeEditor.getContent();
< / script>
< / head>
< body>
< div align =centerid =htmlEditor>
< form>
< table>
< tr>
< td>
< textarea name =textareascols =40rows =20class =mceEditor>< / textarea>
< / td>
< / tr>
< tr>
< td align =center>
< input type =submitvalue =צורמאמר/>
< / td>
< / tr>
< / table>
< / form>
< / div>
< / body>
< / html>
当表单发布时,我想要获取textarea中的数据,把它放到数据库中。
问题是我该怎么做,考虑到我使用php和$ _POST ..
我知道有这个函数:tinyMCE.activeEditor.getContent();
但它是一个javascript函数。如何从该javascript函数获取数据并将其放入我的php代码中,以便我可以使用它将其放入我的数据库中?!?!?
在你的情况下,你必须使用 $ _ POST ['textareas']
来获取它,因为'textareas'是 $ <$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $'是客户端,所以你可以在页面上获取内容(提交之前)。
无论如何,如Amila所说的,您应该添加 method =post
到您的表单中。
This is how my form looks like:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>צור כתבה</title>
<script type="text/javascript" src="tiny_mce/jquery.js"></script>
<script type="text/javascript" src="tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({
mode : "textareas",
theme : "advanced",
theme_advanced_toolbar_location : "top",
height:"1000px",
width:"800px",
editor_selector :"mceEditor"
});
tinyMCE.activeEditor.getContent();
</script>
</head>
<body>
<div align="center" id="htmlEditor">
<form >
<table>
<tr>
<td>
<textarea name="textareas" cols="40" rows="20" class="mceEditor"></textarea>
</td>
</tr>
<tr>
<td align="center">
<input type="submit" value="צור מאמר"/>
</td>
</tr>
</table>
</form>
</div>
</body>
</html>
When the form is posted, I want to fetch the data that is inside the textarea as it is and put it into the database.
The question is how do I do it, considering that I use php and $_POST..
I know that there is that function: tinyMCE.activeEditor.getContent();
But it is a javascript function. How do I fetch the data from that javascript function and put into my php code so that I will be able to use it to put into my database?!?!?
In your case you have to get it using $_POST['textareas']
because 'textareas' is the name
of the textarea.
The function tinyMCE.activeEditor.getContent()
is client side, so you can get the content while you are on the page (before the submit).
Anyway as Amila said, you should add the method="post"
to your form.
这篇关于表单发布后,您如何从Tinymce获取内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!