471,073 Members | 1,385 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,073 software developers and data experts.

Saving HTML in a database.

Hi group.
I need to save HTML to a database, but I have to be sure that these text is
well saved, I mean, imagine that you've got a <TEXTAREA> and want to save
the text inside. If the user type an ENTER in the middle of that text then
we need to save this in the database in a format that could be later well
translated.
Does anyone know what function shoul I use or what method should I use?
I've read a few months ago about a function that do this but I don't
remember now.

I hope someone can help me, thanks in advance.

Nuno Paquete.
Jul 23 '05 #1
3 5872

"Nuno Paquete" <nm*@ispgaya.pt> wrote in message
news:40**********************@news.telepac.pt...
Hi group.
I need to save HTML to a database, but I have to be sure that these text is well saved, I mean, imagine that you've got a <TEXTAREA> and want to save
the text inside. If the user type an ENTER in the middle of that text then
we need to save this in the database in a format that could be later well
translated.
Databases have no trouble saving linebreaks.

If you want to turn the linebreak into say a <br>, then you probably would
do that server side a regular expression (or something similar).

Is there a javascript question here?

Jeff
Does anyone know what function shoul I use or what method should I use?
I've read a few months ago about a function that do this but I don't
remember now.

I hope someone can help me, thanks in advance.

Nuno Paquete.

Jul 23 '05 #2
Hi
Is there a javascript question here?

Yes.
Like i said I've read in a book a function that do just that, but I don't
remember the name of the function, and that function is Javascript, I
suppose.

Any more ideas?

Nuno Paquete.
Jul 23 '05 #3
Nuno Paquete wrote:
Hi
> Is there a javascript question here?

Yes.
Like i said I've read in a book a function that do just that, but I don't
remember the name of the function, and that function is Javascript, I
suppose.

Any more ideas?

Nuno Paquete.


"and that function is Javascript" is only true if you are using server-side
Javascript to serve up the content from the database. The mechanism
(function) to change new line characters stored in a database into a <br> for
output as HTML depends entirely on the server-side technology being used.
Note we keep saying "server-side". If you are reading data from a database on
the server, and outputting that to the client as HTML, then you have some
sort of server-side technology available (Perl, PHP, JSP, ASP, ColdFusion,
etc).

The place to change a new line character stored in the database into a <br>
for display as HTML is on the server.

As an example only, if you were using server-side JScript (ASP), you might do
something like:

function newlineToBr(s) {
return s.replace(/\n/g, '<br>');
}

Then you'd use it in your code as:

<td><%= newlineToBr(fieldFromDatabase) %></td>

Other server-side technologies would involve slightly different syntax, but
the concept is the same.

--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html

Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by csgraham74 | last post: by
2 posts views Thread by jessDMiller | last post: by
10 posts views Thread by Nathan Sokalski | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.