Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 643717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:18:47+00:00 2026-05-13T21:18:47+00:00

In my ruby on rails app I am trying to use a Prototype Form.Element.Observer

  • 0

In my ruby on rails app I am trying to use a Prototype Form.Element.Observer to run a count of the characters in a message. This works fine on Firefox/Safari/Chrome, but not on IE. On IE the observer simply does not fire. Is there a fix or a different way of doing this?

My ruby tag looks like this:

<%= countdown_field('txtmsg[memo]','memo-counter', 141, :frequency => 0.10) %>

The countdown_field function looks like this:

  def countdown_field(field_id,update_id,max,options = {})
    function = "$('#{update_id}').innerHTML = (#{max} - $F('#{field_id}').length);"
    count_field_tag(field_id,function,options)
  end

  def count_field_tag(field_id,function,options = {})  
    out = javascript_tag function, :defer => 'defer'
    out += observe_field(field_id, options.merge(:function => function))
    return out
  end

The resultant HTML looks like this:

<textarea class="memo-tag text txtmsg-memo" id="txtmsg[memo]" name="txtmsg[memo]" />
<p>You have <span id="memo-counter">...</span> characters left.</p>

<script defer="defer" type="text/javascript">
  $('memo-counter').innerHTML = (141 - $F('txtmsg[memo]').length);
</script>
<script type="text/javascript">
  new Form.Element.Observer('txtmsg[memo]', 0.1, function(element, value) {
                  $('memo-counter').innerHTML = (141 - $F('txtmsg[memo]').length);})
</script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T21:18:48+00:00Added an answer on May 13, 2026 at 9:18 pm

    First of all you need to add a closing tag for your <textarea> element because it can’t be self-closing, and the cols and rows attributes are mandatory.

    Using the code below I can partially get it working for IE. It decrements the counter as you type characters, but for some reason the Delete, Backspace and cursor keys don’t work when using IE6! It works fine using Firefox 3.6.

    <textarea class="memo-tag text txtmsg-memo" id="txtmsg[memo]" cols="40" rows="2" name="txtmsg[memo]"></textarea>
    <p>You have <span id="memo-counter">...</span> characters left.</p>
    <script type="text/javascript">
      new Form.Element.Observer("txtmsg[memo]", 0.1, function(element, value) {
        $("memo-counter").update(141 - value.length);
      });
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use RSPec to test my Ruby on Rails 3.2 app. When
I use sendmail to send emails from my ruby-on-rails app. I used this awesome
I am trying to use regular expressions in a ruby on rails app to
I am trying to implement ruby on rails app using Capistrano, I am running
Finally deployed my ruby on rails 3.2 app but when trying to open it
I'm new to ruby/rails and trying to build a simple Projects / Tags app
In my ruby(1.9.3) on rails (3.1) app I'm trying to set some conditional behavior
In a Rails 3.0 (Ruby 1.9.2) app I'm trying to encrypt some data using
This is more a general question but my particular case involves a ruby/rails app
Still can't get this working...Rails 3.1.3, Ruby 1.9.2 on Heroku's Cedar Stack. Trying to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.