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

  • SEARCH
  • Home
  • 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 6091323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:18:50+00:00 2026-05-23T12:18:50+00:00

I’m having a problem similar to but not quite the same as one I’ve

  • 0

I’m having a problem similar to but not quite the same as one I’ve seen discussed a lot. Just want to put this out here in case anyone has any insight on this particular situation. I have a series of select boxes and after the last of these has been selected, I want to update a text_field with some text based on the above.

I have the following code in my view (actually in a partial) for the select box:

<%= f.collection_select :xyz_id, @xyzs, :id, :display_name,
                        { :prompt => "Select a XYZ..." },
                        { :onchange => "#{remote_function(:url => {:action => "update_text_field"}, 
                                                          :with => "'abc_id='+$('#foo_abc_id').val()")}",
                          :class  => "blah" } %>

The update_text_field method in the controller does its work and calls replace_html like so:

some_info = foo.bar.first(:order => "id DESC").name

render :update do |page|
  page.replace_html 'myDivId', :partial => "shared/my_partial", :locals => { :some_info => some_info }
end

Finally, my_partial looks like this:

<%= text_field_tag :special_info, some_info, :size => 20, :readonly => "readonly" %>

The partial that contains this partial has this:

<div id="myDivId"><%= render :partial => 'shared/my_partial', 
           :locals => { :some_info => some_info } %></div>

When run, all works well until the replace_html which throws an RJS error:

RJS error:

TypeError: Result of expression
‘element.getElementsByTagName’
[undefined] is not a function

Followed by:

Element.update("myDivId",
"<input id=\"special_info\"
name=\"special_info\"
readonly=\"readonly\" size=\"20\"
type=\"text\" value=\"The right text\"
/>");

Any ideas on the cause of this error?

  • 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-23T12:18:51+00:00Added an answer on May 23, 2026 at 12:18 pm

    I have this working now.

    Lessons:

    1. Use render :partial instead of render :update in the controller
    2. Use unobtrusive JS to issue a get request to the controller
    3. Use :remote => true on the form
    4. Don’t look for solutions or experiment at night when you’ve been working for the past 12+ hours

    The above list definitely seems to be “sufficient”, but I’m not sure if everything in there is “necessary”, but I’m going to move on using the above list for all of the other dynamic input fields on my form.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.