greenflame wrote:
<summary>
why does the show function in the below code not show anything?
</summary>
FYI: It makes it easier to quote your post if you also ask your
question in the body of the post.
It depends on when you are calling those functions. The
document.write() call isn't intended to be used after the page has
finished loading, it is intended to be used by inline script blocks
that get executed before the page is fully parsed.
For example, if you are calling your function in an onclick event, this
would be occurring well after the page has loaded. In that case, you
should be using another technique to modify the DOM, such as
document.createElement() and appendChild(). Using innerHTML or
insertAdjacentHTML allow you to add blocks of HTML in one call, but
they are not standard DOM methods and are not guaranteed to work in all
browsers.
Also, when you use document.write(), you should really be calling
open() and close() before and after the call. Do a quick web search to
pull up some documentation, or check out this link (scroll down to the
"The write() Method" section):
http://www.unix.org.ua/orelly/web/jscript/ch14_01.html