function result into the div by button onclick
<p>I learn javascript and I have problem. I trying put function results into a div by click on button.</p>

<pre><code>&lt;script type="text/javascript"&gt;

function choinka() {

var x=document.getElementById("liczba").value;
var a="W";
var b="W";
var px="15"

for(j=1;j&lt;=x;j++)
{
for(i=j;i&lt;=x;i++)
{
document.write("&lt;span style='color:white;line-height:" + px + "px;'&gt;" + a + "&lt;/span&gt;");
}
document.write("&lt;span style='color:green;background:green;line-height:" + px + "px;'&gt;" + b + "&lt;/span&gt;");
b+="WW";
for(k=j;k&lt;=x;k++)
{
document.write("&lt;span style='color:white;line-height:" + px + "px;'&gt;" + a + "&lt;/span&gt;");
}
document.write("&lt;br /&gt;");
}
for(k=1;k&lt;=x/2;k++)
{
for(m=1;m&lt;=x;m++)
{
document.write("&lt;span style='color:white;line-height:" + px + "px;'&gt;" + a + "&lt;/span&gt;");
}
b="W";
document.write("&lt;span style='color:brown;background:brown;line-height:" + px + "px;'&gt;" + b + "&lt;/span&gt;");

for(m=1;m&lt;=x;m++)
{
document.write("&lt;span style='color:white;line-height:" + px + "px;'&gt;" + a + "&lt;/span&gt;");
}
document.write("&lt;br /&gt;");
}

}

&lt;/script&gt;
</code></pre>

<p>and body contain:</p>

<pre><code>&lt;p&gt;Wielkość: &lt;input type="text" id="liczba" /&gt;&lt;input type="submit" value="Rysuj" onclick="choinka()" /&gt;&lt;/p&gt;

&lt;div id="choinka"&gt;&lt;/div&gt;
</code></pre>

<p>How put results of function choinka() by clicking button into the div#choinka?</p>
