Hi, say I have <input type="checkbox" id="box1" /> and <div id="createhere"></div> and in a javascript file I have:

    var box=document.getElementById("box").checked;
    var s = "";
        s = "<input type="text" name="text" id="text" />"
        document.getElementById("createhere").innerHTML = s;
        s = "";
        document.getElementById("createhere").innerHTML = s;

Now this works BUT it only creates the text box when I refresh the browser(firefox). How can I do the same without refreshing the browser?

You are missing an event to trigger the function. For example ...

 <input type="checkbox" id="box1" onclick="Function Name(argument)">

You'll need to determine the checked state of your checkob. For example after the checkbox is checked, what if the user I checks it.

is onclick=function() on javascript library? The challenge is that I cannot use any javascript in my HTML file, all javascript related code MUST be contained in a javascript file.

Yes, you can do this from your javascript code without modifying your HTML markup.

for example..

<!DOCTYPE html>

<input type="checkbox" id="box1" />
<div id="createhere"></div>


document.getElementById('box1').onclick = function() {
    if (document.getElementById('box1').checked) {
        s = "<input type='text' name='text' id='text' />";
        document.getElementById("createhere").innerHTML = s;
    } else {
        document.getElementById("createhere").innerHTML = "";



tnx, that totally worked