# Call Javascript

**URL:** <https://www.ruby-forum.com/t/call-javascript/164865>\
**Category:** Rails\
**Created:** [April 6, 2009, 8:23pm UTC](https://www.ruby-forum.com/t/call-javascript/164865 "2009-04-06T20:23:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![intern\_ruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/dc4da7/32.png) [@intern\_ruby](https://www.ruby-forum.com/u/intern_ruby)\
**Post date:** [April 6, 2009, 8:23pm UTC](https://www.ruby-forum.com/t/call-javascript/164865/1 "2009-04-06T20:23:43Z")

</div>

I have following code. I have included the javascript file at the top of  
page. Still it is giving errors

CODE:

\<%= f.label :content %\>  
 \<%= f.text\_area :content, {onkeyup="strcount(1);chngcnt(1);" onkeydown="chngcnt(1);" onblur="chngcnt(1);" onfocus="chngcnt(1);} %\>

ERROR:  
compile error  
/home/abc/Desktop/workspace/group\_paging/app/views/messages/new.html.erb:12:  
odd number list for Hash  
…ount(1);chngcnt(1);" onkeydown=“chngcnt(1);” onblur="chngcnt…

Please help me in calling the javascript function on following events.  
Where Am I wrong ?

---

<div class="post-metadata">

**Author:** ![intern\_ruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/dc4da7/32.png) [@intern\_ruby](https://www.ruby-forum.com/u/intern_ruby)\
**Post date:** [April 6, 2009, 8:45pm UTC](https://www.ruby-forum.com/t/call-javascript/164865/2 "2009-04-06T20:45:39Z")

</div>

Solved.

```
<%= f.label :content %><br />
<%= f.text_area :content, 

```

:id=\>“message1”,:onkeyup=\>“strcount(1);chngcnt(1);”  
,:onkeydown=\>“chngcnt(1);” ,:onblur=\>“chngcnt(1);”,  
:onfocus=\>“chngcnt(1);” %\>

Thanks.

---

<div class="post-metadata">

**Author:** ![intern\_ruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/dc4da7/32.png) [@intern\_ruby](https://www.ruby-forum.com/u/intern_ruby)\
**Post date:** [April 6, 2009, 9:03pm UTC](https://www.ruby-forum.com/t/call-javascript/164865/3 "2009-04-06T21:03:26Z")

</div>

> ```
> <%= f.text_area :content, {onkeyup="strcount(1);chngcnt(1);"
> 
> ```
> 
> onkeydown=“chngcnt(1);” onblur=“chngcnt(1);” onfocus="chngcnt(1);} %\>

The errors come from Ruby - inside the \<%%\> tag - not from Javascript.

Google for [ruby option hash], and compare it to what you wrote. You  
need more  
symbols and arrows in there…
