# RJS - Getting and Setting Form Element Values Question

**URL:** <https://www.ruby-forum.com/t/rjs-getting-and-setting-form-element-values-question/97236>\
**Category:** Rails\
**Created:** [July 5, 2006, 8:55pm UTC](https://www.ruby-forum.com/t/rjs-getting-and-setting-form-element-values-question/97236 "2006-07-05T20:55:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![icottee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/3be4f8/32.png) [@icottee](https://www.ruby-forum.com/u/icottee)\
**Post date:** [July 5, 2006, 8:55pm UTC](https://www.ruby-forum.com/t/rjs-getting-and-setting-form-element-values-question/97236/1 "2006-07-05T20:55:45Z")

</div>

I’m still a beginner with RJS so forgive me if this is a simple one -  
but certainly it doesn’t seem logical and googling has not led to .

Given a field with an id of ‘posting\_subject’ I can do the following in  
my controller with RJS.

```
render :update do | page |
  subject = 'this is really something
  page['posting_subject'].value = subject
end

```

And we sing and rejoice. But why can’t I do

```
render :update do | page |
  page['comment_subject'].value = page['posting_subject'].value
end

```

At the Javascript level the error is that we get

```
${'posting_subject'}.value()

```

instead of

```
${'posting_subject'}.value

```

And value is not a function. So, how can I _get_ a value of a form  
element!?

---

<div class="post-metadata">

**Author:** ![icottee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/3be4f8/32.png) [@icottee](https://www.ruby-forum.com/u/icottee)\
**Post date:** [October 2, 2007, 6:56pm UTC](https://www.ruby-forum.com/t/rjs-getting-and-setting-form-element-values-question/97236/2 "2007-10-02T18:56:02Z")

</div>

Ian Cottee wrote:

> ```
> render :update do | page |
> page['comment_subject'].value = page['posting_subject'].value
> end
> 
> ```

I want to know how to do this too.

---

<div class="post-metadata">

**Author:** ![icottee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/3be4f8/32.png) [@icottee](https://www.ruby-forum.com/u/icottee)\
**Post date:** [October 3, 2007, 4:31am UTC](https://www.ruby-forum.com/t/rjs-getting-and-setting-form-element-values-question/97236/3 "2007-10-03T04:31:47Z")

</div>

Nanyang Z. wrote:

> Ian Cottee wrote:
> 
> > ```
> > render :update do | page |
> > page['comment_subject'].value = page['posting_subject'].value
> > end
> > 
> > ```
> 
> I want to know how to do this too.

I have just figured out how to do it!!!

> render :update do |page|  
> page\<\< “$(‘comment\_subject’).value=$(‘posting\_subject’).value”  
> end
