# Using form values

**URL:** <https://www.ruby-forum.com/t/using-form-values/172776>\
**Category:** Rails\
**Created:** [July 27, 2009, 10:26pm UTC](https://www.ruby-forum.com/t/using-form-values/172776 "2009-07-27T22:26:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mpaxton](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/8c91f0/32.png) [@mpaxton](https://www.ruby-forum.com/u/mpaxton)\
**Post date:** [July 27, 2009, 10:26pm UTC](https://www.ruby-forum.com/t/using-form-values/172776/1 "2009-07-27T22:26:50Z")

</div>

Can anyone tell me how to use form field values on a different part of  
your form?

Example

If I have a value being retrieved from the DB like this:

\<%=h number.m1 %\>

how do I take that value and do something like this:

\<%=h number.m1 %\> X 25

Where I multiple the value retrived by 25 and display it in a new TD

Thanks

---

<div class="post-metadata">

**Author:** ![mpaxton](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/8c91f0/32.png) [@mpaxton](https://www.ruby-forum.com/u/mpaxton)\
**Post date:** [July 27, 2009, 10:48pm UTC](https://www.ruby-forum.com/t/using-form-values/172776/2 "2009-07-27T22:48:56Z")

</div>

I’m not sure I understand, but I would guess the answer is:

\<%=h number.m1 \* 25 %\>

On Mon, Jul 27, 2009 at 4:26 PM, Mark P. \<  
removed\_email\_address@domain.invalid\> wrote:

> >

# –

Jim  
[http://www.thepeoplesfeed.com/contribute](http://www.thepeoplesfeed.com/contribute)

---

<div class="post-metadata">

**Author:** ![mpaxton](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/8c91f0/32.png) [@mpaxton](https://www.ruby-forum.com/u/mpaxton)\
**Post date:** [July 27, 2009, 10:53pm UTC](https://www.ruby-forum.com/t/using-form-values/172776/3 "2009-07-27T22:53:51Z")

</div>

James E. wrote:

> I’m not sure I understand, but I would guess the answer is:
> 
> \<%=h number.m1 \* 25 %\>
> 
> On Mon, Jul 27, 2009 at 4:26 PM, Mark P. \<  
> removed\_email\_address@domain.invalid\> wrote:
> 
> > >
> 
> # –
> 
> Jim  
> [http://www.thepeoplesfeed.com/contribute](http://www.thepeoplesfeed.com/contribute)

Thanks for the reply, what I am trying to do is take the value from

\<%=h number.m1 %\> and do this: ref to td above X 25

I don’t know how to reference the results from the first td in order to  
do the math I want to in a different td.

I hope I made a little more sense.

Thanks

---

<div class="post-metadata">

**Author:** ![mpaxton](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/8c91f0/32.png) [@mpaxton](https://www.ruby-forum.com/u/mpaxton)\
**Post date:** [July 28, 2009, 12:19am UTC](https://www.ruby-forum.com/t/using-form-values/172776/4 "2009-07-28T00:19:40Z")

</div>

On Mon, Jul 27, 2009 at 1:53 PM, Mark  
Preston[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> … what I am trying to do is take the value from
> 
> \<%=h number.m1 %\> and do this: ref to td above X 25
> 
> I don’t know how to reference the results from the first td in order to  
> do the math I want to in a different td.
> 
> I hope I made a little more sense.

Not really. You’re not doing _anything_ “in a td” – you’re generating  
markup in a view (unless you’re trying to describe using JavaScript  
to interactively set this value in the client).

number.m1 is the same no matter where you refer to it in any given  
page, so what was already suggested is exactly right:

\<%=h number.m1 %\> \<%=h number.m1 \* 25 %\>

If that’s not the answer, please try to explain what you want to do a  
little more clearly.

–  
Hassan S. ------------------------ removed\_email\_address@domain.invalid  
twitter: @hassan
