# How to add extra value to form?

**URL:** <https://www.ruby-forum.com/t/how-to-add-extra-value-to-form/84249>\
**Category:** Rails\
**Created:** [February 2, 2007, 6:24pm UTC](https://www.ruby-forum.com/t/how-to-add-extra-value-to-form/84249 "2007-02-02T18:24:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matt\_Mueller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/97f17d/32.png) [@Matt\_Mueller](https://www.ruby-forum.com/u/Matt_Mueller)\
**Post date:** [February 2, 2007, 6:24pm UTC](https://www.ruby-forum.com/t/how-to-add-extra-value-to-form/84249/1 "2007-02-02T18:24:27Z")

</div>

Ok, I am a total n00b when it comes to this stuff, but am working as a  
designer on a project built on ror. Here’s my question.

I want to add js tooltips to pop up when a form field is focused on.  
This is easy enough…have the script running, works fine. The problem  
is, how do I add the necessary value (tooltiptext) into the form field.

For example, I would like to do something like this: \<%= text\_field  
‘person’, ‘name’, :class =\> ‘formtext’ , :tooltiptext = \> ‘This is the  
text’ %\>

But obviously ror doesn’t understand tooltiptext…is there some way to  
just append an html value (i.e. tooltiptext=x) to the text field call?  
Or another workaround?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Matt\_Mueller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/97f17d/32.png) [@Matt\_Mueller](https://www.ruby-forum.com/u/Matt_Mueller)\
**Post date:** [February 2, 2007, 7:11pm UTC](https://www.ruby-forum.com/t/how-to-add-extra-value-to-form/84249/2 "2007-02-02T19:11:05Z")

</div>

are you taking about the off-yellow box that the browser shows you  
when you mouse over something? or are you talking about a homemade  
tooltip solution?

if it’s the first, it is the ‘title’ attribute, so you would want to  
do :title =\> ‘look at me!’ in the html options for the tag. however,  
i believe IE will show you the alt attribute, so if you do both :alt  
and :title, you should be safe.

---

<div class="post-metadata">

**Author:** ![Matt\_Mueller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/97f17d/32.png) [@Matt\_Mueller](https://www.ruby-forum.com/u/Matt_Mueller)\
**Post date:** [February 2, 2007, 9:01pm UTC](https://www.ruby-forum.com/t/how-to-add-extra-value-to-form/84249/3 "2007-02-02T21:01:23Z")

</div>

No, I am talking about a homemade solution. So title and alt attributes  
won’t work.

---

<div class="post-metadata">

**Author:** ![Matt\_Mueller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/97f17d/32.png) [@Matt\_Mueller](https://www.ruby-forum.com/u/Matt_Mueller)\
**Post date:** [February 2, 2007, 10:05pm UTC](https://www.ruby-forum.com/t/how-to-add-extra-value-to-form/84249/4 "2007-02-02T22:05:23Z")

</div>

well then you are going to have to rely on using the element events to  
show/hide your tooltips

something like:

\<%= text\_field …, :onfocus =\> “show\_tooltip(…)”, :onblur =\>  
“hide\_tooltip(…)” %\>

i don’t know how you are implementing your tooltips so i can’t really  
provide more than that.
