RJS - Getting and Setting Form Element Values Question

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!?

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.

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