textarea输入的弹出预览 [英] Popup preview of textarea input

查看:238
本文介绍了textarea输入的弹出预览的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为帖子创建一个预览功能,使人们可以查看他们输入到textarea中的内容的输出,一旦提交,该内容将如何显示.论坛使用bbcode,并且不允许在帖子中使用html,并且textarea框的ID为"message"

I want to create a preview function for posts that allows people to view the output of what they enter into a textarea how it would appear once submitted. The forum uses bbcode and does not allow html in posts and the id of the textarea box is "message"

任何人都可以帮助我创建一个弹出窗口,该弹出窗口可以在弹出窗口中预览此帖子,而无需将其任何数据传递到数据库并返回数据库?

Can anyone help me create a popup that would preview this post in a popup window without passing any of its data to a database and back?

我意识到,我真的应该提供更多的信息.​​..基本上,我们有一个

I should really have supplied more info, I realise... Basically we have a post form in the form of

<textarea id=\"message\" name=\"message\" style=\"width:515; height:160; font-family: Verdana; font-size: 8pt; color: #000000\" onKeyDown=\"countit()\"></textarea>

带有提交按钮

<input type=\"image\" src=\"newlayout/images/reply.png\" height=\"35\" width=\"109\" border=\"0\" alt=\"Submit\">

单击该窗体后,会将其发送到另一个页面,该页面将从该页面插入数据库.我希望在livejournal上有一个预览按钮,在其中创建一个新的弹出窗口,并显示帖子的外观.我查看了livejournal上的源代码,它提供了jQuery,因此我尝试了此处给出的代码:

When it's clicked, the form gets sent to another page, from where it's inserted into the database. I would like there to be a preview button like the one on livejournal, where a new popup gets created and shows what the post would look like. I looked at the source code on livejournal and it supplied jQuery, so I tried the code given here: http://haacked.com/archive/2009/12/15/live-preview-jquery-plugin.aspx However, this did not work, as nothing showed up and also I wasn't fond of the live preview idea.

我还从此处尝试了JavaScript代码: http://www.codingforums.com /showthread.php?t=174810 ,但再次没有提出任何建议...

I also tried a javascript code from here: http://www.codingforums.com/showthread.php?t=174810, but once again, it didn't come up with anything...

我希望这是个好信息,如果我还需要添加其他内容,请告诉我:)

I hope that's good info, if I should include anything else, please let me know :)

推荐答案

这个问题已经接近为我编写代码"了,但是如果您只是在寻求最佳方法的帮助,请参考以下内容:

This question is getting close to "write my code for me", but if you're just trying to get help with the best approach, here are a few:

最干净的将是一个按钮(通过javascript)更改表单的actiontarget并触发Submit()...这会将所有数据通过发布发送到模板页面,该页面可以拾取$ _POST数据并将其放入模仿实时模板的模板中.

The cleanest would be have a button that (via javascript) changes the action and target of the form and triggers a submit()... this would send all the data via post to a template page which can pick up the $_POST data and place it into a template that mimics the live template.

或者,您可以让JavaScript/Jquery捕获所有字段值,并在javascript中构建HTML模板,然后将其传递到页面上的div中,该页面的样式一直看起来像(a)弹出式窗口, (b)具有模仿实时页面的CSS.

Alternately, you could have JavaScript/Jquery grab all the field values, and build the HTML template in javascript and then pass this into div on the page that has been styles to look (a) like a pop-up and (b) has css that mimics the live page.

有很多方法可以做到这一点,但是两者都可以.如果您尝试某些操作并陷入困境,请告诉我们,我们会帮助您.

There are lots of ways to do this, but those would both work. If you try something and get into a tight spot, let us know and we'll give you a hand.

这篇关于textarea输入的弹出预览的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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