# Refreshing a div with preformated text

**URL:** <https://www.ruby-forum.com/t/refreshing-a-div-with-preformated-text/136415>\
**Category:** Rails\
**Created:** [May 1, 2008, 9:59pm UTC](https://www.ruby-forum.com/t/refreshing-a-div-with-preformated-text/136415 "2008-05-01T21:59:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![joel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9bd4f/32.png) [@joel](https://www.ruby-forum.com/u/joel)\
**Post date:** [May 1, 2008, 9:59pm UTC](https://www.ruby-forum.com/t/refreshing-a-div-with-preformated-text/136415/1 "2008-05-01T21:59:28Z")

</div>

Hello,

Just would like to know how I can refresh a div with formatted text  
( html code ) on user onclick action on menu items. I guess I could to  
this with prototype but should I use the link\_remote\_tag ? In my case  
there’s no need to a make a remote ajax call to whatever controller  
action but only put pre-defined formatted text in a div.

Regards,

Joel

---

<div class="post-metadata">

**Author:** ![joel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9bd4f/32.png) [@joel](https://www.ruby-forum.com/u/joel)\
**Post date:** [May 1, 2008, 10:21pm UTC](https://www.ruby-forum.com/t/refreshing-a-div-with-preformated-text/136415/2 "2008-05-01T22:21:29Z")

</div>

For the user onclick action you can use replace(). (or replace\_html  
depending on whether you want to keep your div or not.)

Something like:  
\<input type=“button” value=“Update” \<%=  
“onclick=$(div\_id).replace(

# Hello
);” %\>\>

Hope this helps,

Alan

---

<div class="post-metadata">

**Author:** ![joel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9bd4f/32.png) [@joel](https://www.ruby-forum.com/u/joel)\
**Post date:** [May 1, 2008, 11:17pm UTC](https://www.ruby-forum.com/t/refreshing-a-div-with-preformated-text/136415/3 "2008-05-01T23:17:20Z")

</div>

Have a look at link\_to\_function–that will write client-side javascript  
that doesn’t bother the server.
