Tuesday, June 30, 2009

How to update page text using javascript (and prototype)

$('blah').innerHTML = '${valueToSet}';
<label id="blah"/>

Note: .innerText only works in IE.

And if you want to display end-of-line characters correctly, for example, if the data has been entered using a textfield (using Freemarker and prototype)

$('commentsView').innerHTML = '${closeout.comments!""?js_string}'; 
<label id="commentsView"/>

0 comments: