0
<html>
<head>
</head>
<body> 

<div id = "start">
<h3>Start</h3>
<script>
    if(Go==false)
        document.write("<p>None </p>");
    else
        document.write("<p>Month: Day: Hour: Min: </p>");
</script>
</div>
<script>

    var change = function(){
        document.getElementById('start').innerHTML +=document.write("<p>NO</p>");
    };
</script>
<input type = "button" value =start onClick = "change(); return false;"/>

<body>
</html>

With this it refreshes the page and I need it to be added to the div "start". Any Ideas? I have been looking up things online with fixes and none seem to work for me. I use chrome, I don't know if that will help.

Mike
  • 2,132
  • 3
  • 20
  • 33
alex wilhelm
  • 233
  • 5
  • 16

3 Answers3

2

Try this:

var change = function(){
    document.getElementById('start').innerHTML += "<p>NO</p>";
};
sjkm
  • 3,887
  • 2
  • 25
  • 43
0

This is a similar question of question on SO. Is as to avoid of the use document.write("<p>NO</p>"); because this needs to refresh page.

Then I suggest for you use document.getElementById('start').innerHTML +="<p>NO</p>";

Or create the element!!

var p= document.createElement('P');
           p.appendChild( document.createTextNode("NO") );
           document.getElementById("start").appendChild(p);
Community
  • 1
  • 1
Mirko Cianfarani
  • 2,023
  • 1
  • 23
  • 39
0

Yup, what sjkm said. document.write does not return anything, it just appends whatever you give it to the end of the document. Also, your Go variable isn't declared and has no value assigned to it