<form id="form">
<input type="checkbox"><br>
<input type="checkbox"><br>
<input type="checkbox"><br>
<input type="checkbox"><br>
</form>
<script>
window.onload = function () {
var form = document.getElementById('form');
form.onclick = function (e) {
e = e || event;
var target = e.target || e.srcElement;
if (target.type == 'checkbox') {
var next = target.nextSibling;
if (next && next.tagName == 'DIV') {
if (next.style.display == 'inline') {
next.style.display = 'none';
} else {
next.style.display = 'inline';
}
} else {
var div = document.createElement('div');
div.style.display = 'inline';
div.innerHTML = '<input><span style="cursor: pointer" onclick="this.previousSibling.value=\'\'"> x</span>';
this.insertBefore(div, next);
}
}
}
}
</script>