# How to clear an input box from the controller?

**URL:** <https://www.ruby-forum.com/t/how-to-clear-an-input-box-from-the-controller/184488>\
**Category:** Rails\
**Created:** [March 3, 2010, 12:04pm UTC](https://www.ruby-forum.com/t/how-to-clear-an-input-box-from-the-controller/184488 "2010-03-03T12:04:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hostep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/a88e57/32.png) [@hostep](https://www.ruby-forum.com/u/hostep)\
**Post date:** [March 3, 2010, 12:04pm UTC](https://www.ruby-forum.com/t/how-to-clear-an-input-box-from-the-controller/184488/1 "2010-03-03T12:04:45Z")

</div>

hi!

I have a normal text input box on a page. The controller renders results  
to another div, but I need to clear the content of the input box after a  
search. Most of my interaction is done with something like

page.replace\_html(‘div’,newcontent)

but in this case the element I am addressing is a inputbox and doesn’t  
have inner html, only a value? how can I adress this value?

As always, your patience is greatly appreciated.

Regards

Pieter

---

<div class="post-metadata">

**Author:** ![hostep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/a88e57/32.png) [@hostep](https://www.ruby-forum.com/u/hostep)\
**Post date:** [March 3, 2010, 2:39pm UTC](https://www.ruby-forum.com/t/how-to-clear-an-input-box-from-the-controller/184488/2 "2010-03-03T14:39:43Z")

</div>

page[‘search\_field’].value = ‘’

Replace ‘search\_field’ with the actual ID of your search field

---

<div class="post-metadata">

**Author:** ![hostep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/a88e57/32.png) [@hostep](https://www.ruby-forum.com/u/hostep)\
**Post date:** [March 3, 2010, 3:20pm UTC](https://www.ruby-forum.com/t/how-to-clear-an-input-box-from-the-controller/184488/3 "2010-03-03T15:20:34Z")

</div>

Sharagoz – wrote:

> page[‘search\_field’].value = ‘’
> 
> Replace ‘search\_field’ with the actual ID of your search field

Hi Sharagoz

Thanks a million. Obvious… My brain is getting to old for this stuff.

Would it be possible to set other specific attributes of DOM elements in  
the same way?

eg would

page[‘id\_of\_element’].enabled = false

work?

thanks again

---

<div class="post-metadata">

**Author:** ![hostep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/a88e57/32.png) [@hostep](https://www.ruby-forum.com/u/hostep)\
**Post date:** [March 3, 2010, 3:31pm UTC](https://www.ruby-forum.com/t/how-to-clear-an-input-box-from-the-controller/184488/4 "2010-03-03T15:31:35Z")

</div>

> Would it be possible to set other specific attributes of DOM elements in  
> the same way?  
> Why dont you experiment with it yourself to learn this, now that you  
> know the syntax

> would page[‘id\_of\_element’].enabled = false work?  
> I dont think so, but “disabled = true” will work 🙂

---

<div class="post-metadata">

**Author:** ![hostep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/a88e57/32.png) [@hostep](https://www.ruby-forum.com/u/hostep)\
**Post date:** [March 3, 2010, 3:59pm UTC](https://www.ruby-forum.com/t/how-to-clear-an-input-box-from-the-controller/184488/5 "2010-03-03T15:59:32Z")

</div>

Sharagoz – wrote:

> > Would it be possible to set other specific attributes of DOM elements in  
> > the same way?  
> > Why dont you experiment with it yourself to learn this, now that you  
> > know the syntax
> 
> > would page[‘id\_of\_element’].enabled = false work?  
> > I dont think so, but “disabled = true” will work 🙂

I am humbled. Thanks again!
