I am trying to make sense of the uses of the document.all and/or document.getElementbyId javascript functions. I just thought that I could use this code:
<script type="text/javascript">
function AppendNewLine()
{
document.write("In Function");
var myPar = document.getElementbyId("myP");
myPar+="\n";
myPar+="New Line?\n";
document.write(MyPar);
}
</script>
<p id="myP" value="value" >Append New Line<br /></p>
<input type="button" value="Append" onclick="AppendNewLine()" />
to append a new line to a paragraph on the page. Can someone tell me if I am on the right track, and where I went wrong, or am I all together wrong and where should I restart, and especially, WHY this doesn't work?
From this link:
http://www.webdeveloper.com/forum/archive/index.php/t-93903.html
I see a way to append to the whole document, but not to an individual <p> element.
I had already begun to change my code, when I realized that it wasn't going to be applied to the p element:
<html>
<head>
<script type="text/javascript">
function AppendNewLine()
{
document.write("In Function");
myText = document.createTextNode('\nNew Line?');
myParagraph.appendChild(myText);
var myPar = document.getElementbyId("myP");
myPar+="\n";
myPar+="";
document.write(MyPar);
}
</script>
</head>
<body>
<p id="myP" value="value" >Append New Line<br /></p>
<input type="button" value="Append" onclick="AppendNewLine()" />
</body>