| Page 1 of 1 | [ 9 posts ] |
|
Guys,
I've been stumbling on this problem, I'm learning to use the YUI Rich Text Editor. The editor appeared and I typed in some text. When I clicked submit, the data for the <textarea> is not shown via php $_POST['message']. Any idea ? Below is my code. Thanks a lot. Code: <?php if (isset($_POST['submit'])) { echo 'You entered: <br />'; echo 'name: ' . $_POST['name'] . '<br />'; // this works fine echo $_POST['message']; // this does not work } ?> <!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>YUI Editor Test</title> <!-- Skin CSS file --> <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.8.0r4/build/assets/skins/sam/skin.css"> <!-- Utility Dependencies --> <script src="http://yui.yahooapis.com/2.8.0r4/build/yahoo-dom-event/yahoo-dom-event.js"></script> <script src="http://yui.yahooapis.com/2.8.0r4/build/element/element-min.js"></script> <!-- Needed for Menus, Buttons and Overlays used in the Toolbar --> <script src="http://yui.yahooapis.com/2.8.0r4/build/container/container_core-min.js"></script> <!-- Source file for Rich Text Editor--> <script src="http://yui.yahooapis.com/2.8.0r4/build/editor/simpleeditor-min.js"></script> <script type="text/JavaScript"> var myEditor = new YAHOO.widget.SimpleEditor('msgpost', { height: '300px', width: '600px', dompath: true //Turns on the bar at the bottom }); myEditor.render(); </script> </head> <body class="yui-skin-sam"> <form method="post" action="index.php"> <textarea name="message" id="msgpost" cols="50" rows="10"></textarea> <input type="text" name="name" /><br /> <input type="submit" name="submit" value="Submit" /> </form> </body> </html> |
|
http://developer.yahoo.com/yui/editor/#getdata
you need to set the 'handleSubmit' option or create your own submit handler function. |
|
Thanks John.
How do I set the 'handleSubmit' configuration option ? According to YUI, the following code: YAHOO.util.Event.on('somebutton', 'click', function() { //Put the HTML back into the text area myEditor.saveHTML(); //The var html will now have the contents of the textarea var html = myEditor.get('element').value; }); will store the form submitted data into "html". Still, this is a JavaScript variable. Now, if I need to dump that data to a database, I will need to store that JavaScript variable value (html) into a server variable, say PHP. Is there a way to achieve this ? Thanks so much. |
|
Just change this:
Code: <script type="text/JavaScript"> var myEditor = new YAHOO.widget.SimpleEditor('msgpost', { height: '300px', width: '600px', dompath: true //Turns on the bar at the bottom }); myEditor.render(); </script> To this: Code: <script type="text/JavaScript"> var myEditor = new YAHOO.widget.SimpleEditor('msgpost', { height: '300px', width: '600px', dompath: true, //Turns on the bar at the bottom handleSubmit: true }); myEditor.render(); </script> |
|
Hi Dav,
Thanks for your help. I followed your instruction and added the attribute handleSubmit: true to the myEditor object. The PHP post variable $_POST['message'] now works but at the trade off of the disappearance of the editor. The editor is totally gone except for the textarea. What's going on ? Thanks again. |
|
did you get the comma right after "dompath: true, " ?
I copy and pasted the whole thing onto my testing server and it renders fine. |
|
Thanks John. It works now. Thanks again.
|
|
Merci JhonG ,votre Réponse m'a sauvée beaucoup,j'étais totalement bloquée, Merci encore
|
|
Hi! I am sekhar.
I was just added the YUI Rich text box to a site. I am also placed a text box above the Yahoo rich text box. Whenever i resize my rich text box, the textbox above the rich text box should also resize to the same width. How can i do this? |
| Page 1 of 1 | [ 9 posts ] |
| You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum |
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info
Powered by phpBB® Forum Software © phpBB Group