# Text\_field value as a local variable in in-line template function

**URL:** <https://www.ruby-forum.com/t/text-field-value-as-a-local-variable-in-in-line-template-function/184661>\
**Category:** Rails\
**Created:** [March 6, 2010, 1:10am UTC](https://www.ruby-forum.com/t/text-field-value-as-a-local-variable-in-in-line-template-function/184661 "2010-03-06T01:10:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Grary](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/91b2a8/32.png) [@Grary](https://www.ruby-forum.com/u/Grary)\
**Post date:** [March 6, 2010, 1:10am UTC](https://www.ruby-forum.com/t/text-field-value-as-a-local-variable-in-in-line-template-function/184661/1 "2010-03-06T01:10:07Z")

</div>

Hi,

I’d like to conserve the sum total of several text fields on my form,  
even as I set them to blank upon a user link action.

The following in-line snippet fails to store the value of my sum total  
field locally for eventual reassignment. (I am re-assigning it because  
the fields all have an observe\_field nexus relating them, which  
complicates things.)

\<%= link\_to\_function “Itemize expenses” do |page|  
…  
local\_var = page[:operating\_expense\_admin\_total].value  
page[:operating\_expense\_admin\_other].value = “”  
page[:operating\_expense\_admin\_advertising].value = “”  
page[:operating\_expense\_admin\_management\_fee].value = “”  
page[:operating\_expense\_admin\_total].value = local\_var  
end %\>

What is the proper way to extract values, store them locally and  
reassign them , per the attempt above?

Thanks,

Grar
