Saving HTML in a database.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nuno Paquete

    #1

    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.
  • Jeff Thies

    #2
    Re: Saving HTML in a database.


    "Nuno Paquete" <nmp@ispgaya.pt > wrote in message
    news:40dc6730$0 $1834$a729d347@ news.telepac.pt ...[color=blue]
    > Hi group.
    > I need to save HTML to a database, but I have to be sure that these text[/color]
    is[color=blue]
    > 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.[/color]

    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


    [color=blue]
    > 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.[/color]


    Comment

    • Nuno Paquete

      #3
      Re: Saving HTML in a database.

      Hi[color=blue]
      > Is there a javascript question here?[/color]
      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.

      Comment

      • Grant Wagner

        #4
        Re: Saving HTML in a database.

        Nuno Paquete wrote:
        [color=blue]
        > Hi[color=green]
        > > Is there a javascript question here?[/color]
        > 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.[/color]

        "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(fie ldFromDatabase) %></td>

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

        --
        | Grant Wagner <gwagner@agrico reunited.com>

        * Client-side Javascript and Netscape 4 DOM Reference available at:
        *


        * 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

        Comment

        Working...