New Line / Textbox and Javascrip

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Microsoft Newsserver

    #1

    New Line / Textbox and Javascrip

    Hi Folks

    I cant get access to books on line at the moment but I cant get to this
    newsgroup, so I have a question.

    We are passing a string of text to a textbox from which the value is popped
    up by the web page if there is anything in it.

    The problem is we want to have newlines "\n" in the javascript alert, but
    these are treated literally in the translation. What can I do to ensure the
    new lines make it into the alert.

    this.MyTextBox. Text = "LineOne\nLineT wo";


    ///// ON CLIENT SIDE

    alert( $get(MyTextBox) .value );


    Thanks


  • George

    #2
    Re: New Line / Textbox and Javascrip

    The \n is so called escaped characters and process by the compiler.

    For example:
    s = 'aaa\nbbb';
    alert(s)
    will show you 2 lines because when compiler compiles
    s = 'aaa\nbbb' it will replace \n with 0x0A.

    when you have code like this
    alert( $get(MyTextBox) .value )

    The MyTextBox.value is not proccessed by compiler so the value shown as it
    is.
    so the MyTextBox.value should already have the 0x0A in it (and not \n)

    So try to put it there like this (in C#)
    this.MyTextBox. Text = "LineOne\x0ALin eTwo";

    It might not work though if MyTextBox is a input type="text" and not
    <textareasinc e <input type=textis a single line textbox.


    George.






    "Microsoft Newsserver" <me@nowhere.com wrote in message
    news:uV6GNcLGJH A.4228@TK2MSFTN GP05.phx.gbl...
    Hi Folks
    >
    I cant get access to books on line at the moment but I cant get to this
    newsgroup, so I have a question.
    >
    We are passing a string of text to a textbox from which the value is
    popped up by the web page if there is anything in it.
    >
    The problem is we want to have newlines "\n" in the javascript alert, but
    these are treated literally in the translation. What can I do to ensure
    the new lines make it into the alert.
    >
    this.MyTextBox. Text = "LineOne\nLineT wo";
    >
    >
    ///// ON CLIENT SIDE
    >
    alert( $get(MyTextBox) .value );
    >
    >
    Thanks
    >

    Comment

    Working...