How to create a textarea dependant on flag in javascript

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

    How to create a textarea dependant on flag in javascript

    When I sometimes want to debug something on a browser without a firebug
    console, I have been using a textarea to which I can print stuff.

    So my HTML calls my big script file, and further down in my HTML I put
    up a textarea. When a 'debug' condition in my .js is in modeOne, I
    write msgs to that textarea. When it's in modeTwo, I write to the
    firebug console, in modeThree no messages get written.

    I'd like to have that textarea not visible in the latter two modes.

    SO my html contains:

    <html>
    ....
    <script type='applicati on/x-javascript' src='/myfiles/dowork.js'>
    </script>
    ....
    other html
    ....
    <form name="mydebug">
    DEBUG Data:
    <textarea rows="40" cols="30" name="outdebg"D ebug msgs:
    </textarea>

    </form>
    </html>


    Is there some means to make that form part display conditionally? Any
    suggestions for a newbie? I suppose moving it into the javascript makes
    sense, where an if-statement can be used. But then how does one make a
    textarea like that show up?

    Thanx

    Ross.
  • David Mark

    #2
    Re: How to create a textarea dependant on flag in javascript

    On Nov 4, 2:48 pm, Ross <ab...@fgh.ijkw rote:
    When I sometimes want to debug something on a browser without a firebug
    console, I have been using a textarea to which I can print stuff.
    You mean without an error console. Firebug is optional.
    >
    So my HTML calls my big script file, and further down in my HTML I put
    up a textarea.   When a 'debug' condition in my .js is in modeOne, I
    write msgs to that textarea. When it's in modeTwo, I write to the
    firebug console, in modeThree no messages get written.
    >
    I'd like to have that textarea not visible in the latter two modes.
    That is sensible.
    >
    SO my html contains:
    >
    No doctype?
    <html>
    ...
    <script type='applicati on/x-javascript' src='/myfiles/dowork.js'>
    type="text/javascript"
    </script>
    ...
    other html
    ...
    <form name="mydebug">
            DEBUG Data:
    Put that in a label.
             <textarea rows="40" cols="30" name="outdebg"D ebug msgs:
    </textarea>
    >
    </form>
    </html>
    >
    Is there some means to make that form part display conditionally?  Any
    Yes, the simplest way is to use the document.write method.

    The write() method of the Document interface writes text in one or more TrustedHTML or string parameters to a document stream opened by document.open().


    You could also create the form using document.create Element and add it
    to the DOM with appendChild. Unfortunately, IE makes this method more
    difficult than it should be.

    Comment

    • Ross

      #3
      Re: How to create a textarea dependant on flag in javascript

      David Mark wrote:
      On Nov 4, 2:48 pm, Ross <ab...@fgh.ijkw rote:
      You could also create the form using document.create Element and add it
      to the DOM with appendChild. Unfortunately, IE makes this method more
      difficult than it should be.
      Thanks David,

      That is the method I went with. I stuck a <div id="makeitHere" </div>
      into my HTML doc, then was able to find that in the javascript and use
      the appendChild to stick that text area in there precisely where I
      wanted it. Works great.

      Now I have a flag I can set to say whether I am on FF with firebug
      loaded, in which case all my debug messages go to that console. When in
      another browser without firefox & a console, the flag is set
      differently and the textarea pops up and all my error messages go into
      that textarea.

      I don't use IE at all, so any extra complexities from those
      troublemakers aren't an issue ;-)

      Ross.

      Comment

      Working...