# Get content from HTML element in Rails

**URL:** <https://www.ruby-forum.com/t/get-content-from-html-element-in-rails/185227>\
**Category:** Rails\
**Created:** [March 16, 2010, 1:25pm UTC](https://www.ruby-forum.com/t/get-content-from-html-element-in-rails/185227 "2010-03-16T13:25:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![iggar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/a88e57/32.png) [@iggar](https://www.ruby-forum.com/u/iggar)\
**Post date:** [March 16, 2010, 1:25pm UTC](https://www.ruby-forum.com/t/get-content-from-html-element-in-rails/185227/1 "2010-03-16T13:25:27Z")

</div>

Hey,  
I’m looking for a way to get the content of my div in my Rails view. I  
would like the literal HTML content, so only HTML and no Rails  
I thought inner\_html would work, but I get a RJS exception (TypeError:  
$(“content”).innerHtml is not a function)

Does anyone know how I can get the content? Thanks!

In my controller I use this code:

```auto
def save_test
    render :update do |page|
        page['content'].innerHTML
    end
end
```

Some more context maybe? I get a HTML form (without the form tags  
themselves) and put it into a rails form. What I want is that the user  
changes checkboxes, radiobuttons, fills out input fields etc and when  
the user saves, I want the literal changed content of the form as a  
string to save it to my database.  
The reason for this is that the several provided forms differ a lot and  
it’s only used as information, no calculations etc need to be done on  
it.  
So my view looks like this:

```auto
form_remote_tag :url=>{:action => 'save_trainee_evaluation' do %>
<div id="content">
  <%= contract_trainer_trainee.evaluation_template %>
</div>
<%= submit_tag 'Opslaan' %>

<% end %>
```

---

<div class="post-metadata">

**Author:** ![iggar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/a88e57/32.png) [@iggar](https://www.ruby-forum.com/u/iggar)\
**Post date:** [March 16, 2010, 4:44pm UTC](https://www.ruby-forum.com/t/get-content-from-html-element-in-rails/185227/2 "2010-03-16T16:44:47Z")

</div>

Anybody?  
If more info is needed, do ask!  
Thanks

---

<div class="post-metadata">

**Author:** ![iggar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/a88e57/32.png) [@iggar](https://www.ruby-forum.com/u/iggar)\
**Post date:** [March 16, 2010, 5:38pm UTC](https://www.ruby-forum.com/t/get-content-from-html-element-in-rails/185227/3 "2010-03-16T17:38:22Z")

</div>

On 16 Mar 2010, at 16:44, Ignace S. wrote:

> Anybody?  
> If more info is needed, do ask!  
> Thanks

More info is needed

Best regards

Peter De Berdt

---

<div class="post-metadata">

**Author:** ![iggar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/a88e57/32.png) [@iggar](https://www.ruby-forum.com/u/iggar)\
**Post date:** [March 16, 2010, 6:28pm UTC](https://www.ruby-forum.com/t/get-content-from-html-element-in-rails/185227/4 "2010-03-16T18:28:07Z")

</div>

innerHtml is not a function.

innerHTML is.

Larry

---

<div class="post-metadata">

**Author:** ![iggar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/a88e57/32.png) [@iggar](https://www.ruby-forum.com/u/iggar)\
**Post date:** [March 16, 2010, 6:59pm UTC](https://www.ruby-forum.com/t/get-content-from-html-element-in-rails/185227/5 "2010-03-16T18:59:46Z")

</div>

Peter De Berdt wrote:

> On 16 Mar 2010, at 16:44, Ignace S. wrote:
> 
> > Anybody?  
> > If more info is needed, do ask!  
> > Thanks
> 
> More info is needed
> 
> Best regards
> 
> Peter De Berdt

Little more specific? What exactly do you want to know?

Larry Meadors wrote:

> innerHtml is not a function.
> 
> innerHTML is.
> 
> Larry

Yes, you’re right there, but as you can see, I use innerHTML in my  
controller. And the same error message (but then with ‘innerHTML’) is  
triggered.
