How do I set the value between the TEXTAREA tags?

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

    How do I set the value between the TEXTAREA tags?

    Hi,

    If my variable contains

    var v = "Hi<BR/>there<BR/>";

    and attempt to set the value of my textarea like so:

    dojo.byId("appE ditForm:txtDesc ").value = v;

    I actually see the "<BR/>" tags displayed on the screen. I don't want
    this -- preferring to see line breaks. What is the proper way to set
    the HTML between TEXTAREA tags?

    Thanks, - Dave
  • ameshkin

    #2
    Re: How do I set the value between the TEXTAREA tags?

    On Jul 21, 10:32 am, laredotornado <laredotorn...@ zipmail.comwrot e:
    Dave,
    the best way to do this is with PHP/AJAX. But this may not be your
    best option depending on what you're doing. I use the below code
    becasue its simple, but there are many frameworks that can squeeze
    this done to one line of code.


    function ajxPost(){
    var ajaxRequest;

    try{
    // Opera 8.0+, Firefox, Safari
    ajaxRequest = new XMLHttpRequest( );
    } catch (e){
    // Internet Explorer Browsers
    try{
    ajaxRequest = new ActiveXObject(" Msxml2.XMLHTTP" );
    } catch (e) {
    try{
    ajaxRequest = new ActiveXObject(" Microsoft.XMLHT TP");
    } catch (e){
    // Something went wrong
    alert("Your browser broke!");
    return false;
    }
    }
    }
    // ajax function
    ajaxRequest.onr eadystatechange = function(){
    if(ajaxRequest. readyState == 4){
    var ajaxDisplay = document.getEle mentById('texta rea-id');
    ajaxDisplay.inn erHTML = ajaxRequest.res ponseText;
    }
    }


    var queryString = "?variable= " + variable+ "&bankid=" + bankid;

    ajaxRequest.ope n("GET", "php-file-with-content.php" + queryString,
    true);
    ajaxRequest.sen d(null);
    }

    Hi,
    >
    If my variable contains
    >
    var v = "Hi<BR/>there<BR/>";
    >
    and attempt to set the value of my textarea like so:
    >
    dojo.byId("appE ditForm:txtDesc ").value = v;
    >
    I actually see the "<BR/>" tags displayed on the screen.  I don't want
    this -- preferring to see line breaks.  What is the proper way to set
    the HTML between TEXTAREA tags?
    >
    Thanks, - Dave

    Comment

    • RoLo

      #3
      Re: How do I set the value between the TEXTAREA tags?

      On Jul 21, 1:32 pm, laredotornado <laredotorn...@ zipmail.comwrot e:
      Hi,
      >
      If my variable contains
      >
      var v = "Hi<BR/>there<BR/>";
      >
      and attempt to set the value of my textarea like so:
      >
      dojo.byId("appE ditForm:txtDesc ").value = v;
      >
      I actually see the "<BR/>" tags displayed on the screen.  I don't want
      this -- preferring to see line breaks.  What is the proper way to set
      the HTML between TEXTAREA tags?
      >
      Thanks, - Dave
      Theres no way to do it, its like asking the proper way to set an
      iframe inside a textarea...
      theres a reason its called TEXTAREA!

      if you only want to convert <br/to \n, then you should do something
      like,
      dojo.byId("appE ditForm:txtDesc ").value = v.replace(/<br\/>/ig,"\n");

      Comment

      • ameshkin

        #4
        Re: How do I set the value between the TEXTAREA tags?

        On Jul 21, 10:32 am, laredotornado <laredotorn...@ zipmail.comwrot e:
        Now that I think about it, I do not believe this will work for a text
        area. It may not be necessary to put a text area here, and you may
        want to use a div instead. this all depends on exactly what you are
        doing.

        Sorry i could not be more help, but I'm very very new to JS myself and
        I have trouble doing the easiest things.





        >
        If my variable contains
        >
        var v = "Hi<BR/>there<BR/>";
        >
        and attempt to set the value of my textarea like so:
        >
        dojo.byId("appE ditForm:txtDesc ").value = v;
        >
        I actually see the "<BR/>" tags displayed on the screen.  I don't want
        this -- preferring to see line breaks.  What is the proper way to set
        the HTML between TEXTAREA tags?
        >
        Thanks, - Dave

        Comment

        • Suhas Dhoke

          #5
          Re: How do I set the value between the TEXTAREA tags?

          I actually see the "<BR/>" tags displayed on the screen.  I don't want
          this -- preferring to see line breaks.  What is the proper way to set
          the HTML between TEXTAREA tags?
          >
          Then, use the new line feed ("\n") instead of "<BR/>".

          Hope, this will helps you.

          Comment

          • Thomas 'PointedEars' Lahn

            #6
            Re: How do I set the value between the TEXTAREA tags?

            Suhas Dhoke wrote:
            >I actually see the "<BR/>" tags displayed on the screen. I don't want
            >this -- preferring to see line breaks. What is the proper way to set
            >the HTML between TEXTAREA tags?
            >
            Then, use the new line feed ("\n")
            There is no character with that name. There is the Line Feed (LF) character
            (escape sequence: "\n") and the Carriage Return (CR) character ("\r"). Both
            are used for creating a new line: "\r\n" is used on WinDOS, "\n" is used on
            Unices, and "\r" is used on Mac OS up to version 9, among others.
            Therefore, it is probably best to use the escape sequence "\r\n" as it
            satisfies all conceivable markup parsers, including standards-compliant ones.
            instead of "<BR/>".
            <BR/is not likely to be Valid markup anyway. If it should be HTML, then
            it should be <BR>, <Br>, <bRor <br(else it would be equivalent to
            "<BR>&gt;". If it should be XHTML (which should only be used on today's Web
            instead of HTML when absolutely necessary), then it must be <br/>, <br /or
            <br></br(XHTML is case-sensitive), whereas the second form is deemed
            "HTML-compatible" (because many of not most markup parsers do not implement
            the HTML SHORTTAG feature properly).


            PointedEars
            --
            var bugRiddenCrashP ronePieceOfJunk = (
            navigator.userA gent.indexOf('M SIE 5') != -1
            && navigator.userA gent.indexOf('M ac') != -1
            ) // Plone, register_functi on.js:16

            Comment

            Working...