By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,624 Members | 1,643 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,624 IT Pros & Developers. It's quick & easy.

How to create a textarea dependant on flag in javascript

P: n/a
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='application/x-javascript' src='/myfiles/dowork.js'>
</script>
....
other html
....
<form name="mydebug">
DEBUG Data:
<textarea rows="40" cols="30" name="outdebg"Debug 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.
Nov 4 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Nov 4, 2:48*pm, Ross <ab...@fgh.ijkwrote:
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='application/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"Debug 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.

https://developer.mozilla.org/en/DOM/document.write

You could also create the form using document.createElement and add it
to the DOM with appendChild. Unfortunately, IE makes this method more
difficult than it should be.
Nov 5 '08 #2

P: n/a
David Mark wrote:
On Nov 4, 2:48 pm, Ross <ab...@fgh.ijkwrote:
You could also create the form using document.createElement 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.
Nov 6 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.