2

I do not know if my code even works because i cant get past the onlclick is null. i am trying to take text from a textarea and put it into a paragraph in HTML. With a check box. if the box is checked then it will clear the <p> tag. if unchecked it will leave the stuff in the p-tag and just make a new p-tag. thanks guys

window.onload = function()  { 
document.getElementById("paste").onclick = function() {


//var y = document.getElementById('paste').onclick
var paragraph = document.getElementById('box').value;
var x = document.getElementById("write");
var getInfo = document.getElementById('ParaWrite');

 if (x.checked === true)
     paragraph =+ "<p>"+paragraph+"</P>";
 else
 return;
getInfo.innterHTML === paragraph;

  }    
}


HTML 
<!doctype html>
<html>
<head>
<meta charset="utf-8">

<title>TeXt BoX</title>


<link rel="stylesheet" href="../css/normalize.css">
<link rel="stylesheet" href="Textbox.css">


</head>

<body>
<h1></h1>
<form name="form1" id="form1">

<input type='checkbox' name='write' id='write' value='Check' />

<label for='write'>Append Paragraph</label><br/>

<textarea type="text" id="box"/></textarea>

<input  type='button' value="Paste typed text" id="Paste"/>

</form>
<p id="ParaWrite"></p>


<script type="text/javascript" src="TextPara.js"></script>
</body>
</html>
Austen H
  • 31
  • 1
  • 6

2 Answers2

3

id name is case sensitive. Change your onclick assigning call to

document.getElementById("Paste").onclick = 

change paste to Paste

Also it not =+ correct one is +=

999k
  • 6,257
  • 2
  • 29
  • 32
  • Got the Null to go away. Thanks. but my code does not write what is in the textbox to a p-tag. any ideas? – Austen H Feb 05 '13 at 04:24
  • according to your intent i think your last line should be getInfo.innterHTML = paragraph;..i got a run time error in ie check this for that http://stackoverflow.com/questions/7892102/fixing-unknown-runtime-error-in-ie8. – 999k Feb 05 '13 at 04:33
1

Your selector is looking for an id paste, but your element has an id Paste:

var thisWillBeNull = getElementById('paste') ==> null

thisWillBeNull.onclick ==> TypeError: Cannot read property 'onclick' of null

bokonic
  • 1,751
  • 10
  • 12