当表格被张贴时,你如何从Tinymce获得内容?

时间:2021-05-05 09:51:15

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

考虑到我使用的是php和$_POST,问题是我如何做到这一点。

I know that there is that function: tinyMCE.activeEditor.getContent();

我知道有一个函数: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?!?!?

但它是一个javascript函数。如何从javascript函数中获取数据,并将其放入php代码中,这样我就可以将其应用到数据库中?!?

3 个解决方案

#1


3  

In your case you have to get it using $_POST['textareas'] because 'textareas' is the name of the textarea.

在这种情况下,你必须使用$_POST['textareas']来获取它,因为'textareas'是textarea的名称。

The function tinyMCE.activeEditor.getContent() is client side, so you can get the content while you are on the page (before the submit).

函数tinymec . activeeditor.getcontent()是客户端,因此您可以在页面(提交之前)获得内容。

Anyway as Amila said, you should add the method="post" to your form.

不管怎样,正如Amila所说,您应该将方法="post"添加到窗体中。

#2


3  

add form method as post

添加表单方法作为post

<form method="post" action="" >

now you can get the textarea value by $_POST['textareas'];

现在可以通过$_POST['textarea ']获得textarea值;

#3


1  

yes by using post method you will get the value of your input element and for the tinyMice the name of the element to which you have created the instance of the tinyMice in your case it's textares

是的,通过post方法,你会得到输入元素的值对于tinyMice,你已经创建了tinyMice实例的元素的名字在你的例子中,它是tex稗子

#1


3  

In your case you have to get it using $_POST['textareas'] because 'textareas' is the name of the textarea.

在这种情况下,你必须使用$_POST['textareas']来获取它,因为'textareas'是textarea的名称。

The function tinyMCE.activeEditor.getContent() is client side, so you can get the content while you are on the page (before the submit).

函数tinymec . activeeditor.getcontent()是客户端,因此您可以在页面(提交之前)获得内容。

Anyway as Amila said, you should add the method="post" to your form.

不管怎样,正如Amila所说,您应该将方法="post"添加到窗体中。

#2


3  

add form method as post

添加表单方法作为post

<form method="post" action="" >

now you can get the textarea value by $_POST['textareas'];

现在可以通过$_POST['textarea ']获得textarea值;

#3


1  

yes by using post method you will get the value of your input element and for the tinyMice the name of the element to which you have created the instance of the tinyMice in your case it's textares

是的,通过post方法,你会得到输入元素的值对于tinyMice,你已经创建了tinyMice实例的元素的名字在你的例子中,它是tex稗子