格式化文本区域 [英] Formating a text area

查看:93
本文介绍了格式化文本区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个只有一个元素的表单(在Dreamweaver中创建的文本区域。)我希望用户以他想要的任何方式输入表单中的文本(例如段落)并使其输出几乎与它相同除了在不同的网页上输入。我读到了函数nl2br(),但我不明白它是如何工作的。我不需要像我以前输入消息的消息窗口那样复杂的东西,我只是希望我的用户能够输入textarea并且如果他想要一个新的段落


然后他只需要做的就是


点击输入按钮


并且显示文字就像你看到它一样现在。我希望能够做类似的事情。


有什么建议吗?

解决方案


我有一个只包含一个元素的表单(在Dreamweaver中创建的文本区域。)我希望用户以他想要的任何方式输入表单中的文本(例如段落)并使其输出方式大致相同除了在不同的网页上输入它。我读到了函数nl2br(),但我不明白它是如何工作的。我不需要像我以前输入消息的消息窗口那样复杂的东西,我只是希望我的用户能够输入textarea并且如果他想要一个新的段落


然后他只需要做的就是


点击输入按钮


并且显示文字就像你看到它一样现在。我希望能够做类似的事情。


有什么建议吗?



nl2br()听起来像是正确使用的东西。

它的作用是将换行符(nl)转换为(2)换行符( br) - 聪明,嗯?

所以,当用户输入诸如

" hello

这样的东西时这个



a

new

line"

它将这些新行转换为< br />标签,从而保持用户给出的格式。



nl2br()听起来像是正确使用的东西。

它的作用是将换行符(nl)转换为(2)换行符(br) - 聪明,呃?

因此,当用户键入诸如

"的内容时;你好

这个



a



line"

它将这些新行转换为< br />标签,从而保持用户给出的格式。



这是有意义的。

现在在哪里以及如何把它放在代码中?它是在表单页面还是结果页面上(我用来显示文本的页面)?


在表单页面上,我有以下内容:

这是Dreamweaver为striplashes和htmlentities添加的php代码的一部分。

[PHP]

if(!function_exists(" GetSQLValueString"))){

函数GetSQLValueString(


theValue,

I have a form with only one element (a text area created in Dreamweaver.) I want a user to input text in the form in any way he wants(such as paragraphs) and have it output pretty much the same way it was entered except on a different web page. I read about the function nl2br() but I do not understand how it works. I don''t need anything as sophisticated as this message window I used to type in the message, I just want my user to be able to type in a textarea and if he wants a new paragraph

then all he would have to do

is hit the enter button

and the text would be displayed like you are seeing it now. I want to be able to do something similiar.

Any suggestions?

解决方案

I have a form with only one element (a text area created in Dreamweaver.) I want a user to input text in the form in any way he wants(such as paragraphs) and have it output pretty much the same way it was entered except on a different web page. I read about the function nl2br() but I do not understand how it works. I don''t need anything as sophisticated as this message window I used to type in the message, I just want my user to be able to type in a textarea and if he wants a new paragraph

then all he would have to do

is hit the enter button

and the text would be displayed like you are seeing it now. I want to be able to do something similiar.

Any suggestions?

nl2br() sounds like the correct thing to use.
What it does is convert newlines(nl) into(2) linebreaks(br) - smart, eh?
So, when a user types something such as
"hello
this
is
a
new
line"
it converts those new lines into <br /> tags, thus keeping the formatting the user gave.


nl2br() sounds like the correct thing to use.
What it does is convert newlines(nl) into(2) linebreaks(br) - smart, eh?
So, when a user types something such as
"hello
this
is
a
new
line"
it converts those new lines into <br /> tags, thus keeping the formatting the user gave.


That makes sense.
Now where and how to put it in the code? Does it go on the form page or the result page (the page I use to display the text)?

On the form page, I have the following:
Here is a part of php code that Dreamweaver put in for stripslashes and htmlentities.
[PHP]
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString(


theValue,


这篇关于格式化文本区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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