prepend = <<'; tds[i].innerHTML = tds[i].newDate; tds[i].dateIsNew = true; tds[i].addEventListener('click', function(event) { this.innerHTML = (this.dateIsNew ? this.oldDate : this.newDate); this.dateIsNew = !this.dateIsNew; }); } } }); EOT; } function head() { echo script($this->prepend); } }