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 605049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:06:15+00:00 2026-05-13T17:06:15+00:00

I’m running a Rails app and using prototype. The script breaks in IE, but

  • 0

I’m running a Rails app and using prototype. The script breaks in IE, but works in all other browsers. I appreciate any help in guiding toward a fix for this.

Here’s the problem:
My users sell products and varieties of products. The varieties available are dependent on the product. For example, if we’re talking about fruit, the user might select the product “Apple”, then I need to show him varieties of apples to choose from, rather than all the varieties on the whole site.

I use javascript to limit the dropdown choices for varieties so that they are dependent on the product first selected from the dropdown. So if the user selects the product “apple”, then the variety list dynamically limits itself to only varieties of apples. This works great in all browsers, except of course, IE.

In IE, when I select a product from the dropdown, the script fails and the error message is “Object doesn’t support this property or method”

I believe the problem and solution are explained on the following page if you scroll down to the bottom – the section labeled Native Extensions: http://prototypejs.org/learn/extensions

Unfortunately, I’m not very good with javascript yet and I don’t know exactly how to fix the problem in practice based on the explanation from the prototype page.

Here’s the javascript file in question:

var varieties = new Array();
<% for variety in @varieties -%>
  varieties.push (new Array (<%=h variety.product_id %>, "<%=h variety.name %>", <%=h variety.id %>));
<% end -%>


function collectionSelected(e) {
  product_id = e.getValue();
  options = e.next(1).options;
  options.length = 1;
  varieties.each(function(variety) {
    if (variety[0] == product_id) {
      options[options.length] = new Option(variety[1], variety[2]);
    }
  });
}

Any guidance is much appreciated.

Update

This is the html …

users/edit.html.erb

<% javascript 'dynamic_varieties' %>
  <h2>Edit Your Profile</h2>
    <%= render :partial => 'form' %>  

users/_form.html.erb

<% form_for @user do |f| %>     
  <!-- This dynamically adds a new pair of dropdowns, i.e. product & variety -->
  <p class="addProduct"><%= add_season_link "+ Add another product" %></p> 

  <!-- This is where the product & variety dropdowns are rendered -->
  <div id="seasons">
<%= render :partial => 'season', :collection => @user.seasons %>
  </div>
<% end %>

users/_season.html.erb

  <div class="season">
<% new_or_existing = season.new_record? ? 'new' : 'existing' %>
<% prefix = "user[#{new_or_existing}_season_attributes][]" %>

<% fields_for prefix, season do |season_form| -%>
  <%= error_messages_for :season, :object => season %>
      <div class="eachMarketDrop">
          <p class="marketDrop">
            <!-- This is the product dropdown that triggers the dependent variety dropdown -->
            <label for = "user_product_id">Product:</label> <%= season_form.collection_select :product_id, Product.find(:all, :order =>'name'), :id, :name, {:prompt => "Select Product"}, {:onchange => "collectionSelected(this);"} %>
            <label for="user_variety_id">Variety:</label>
            <!-- This is the variety dropdown that is dependent on the product dropdown -->
            <% varieties = season.product ? season.product.varieties : Variety.all %>
            <%= season_form.select :variety_id, options_from_collection_for_select(varieties, :id, :name, season.variety_id), :prompt => "This is optional" %>
          </p>
      </div>
<% end -%>

Update #2

I installed firebug lite and confirmed that the line throwing the error in IE is:

options = e.next(1).options;

The following variations also throw the same error:
options = $(e).next(1).options
options = e.next(‘select’).options;

Any ideas?

  • 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-13T17:06:15+00:00Added an answer on May 13, 2026 at 5:06 pm

    Pullmonkey (http://www.pullmonkey.com/) over at the Rails Forum figured it out. It now works perfectly in all browsers.

    The solution was to change

    {:onchange => "collectionSelected(this);"}   
    

    to

    {:onchange => "collectionSelected($(this));"} %>  
    

    A friend explained it like this:
    “this” is a funny word in JS – it can mean a lot of things. In the original code, your collectionSelected method was being passed the event itself. With the $(this), the collectionSelected method is being passed the item that is triggering the event. So in this case, e.next() makes sense, b/c “e” is the product prompt. In the previous case, when “e” was the event, e.next() doesn’t mean anything!

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

Sidebar

Ask A Question

Stats

  • Questions 302k
  • Answers 302k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If you just want to know which tables are accessed… May 13, 2026 at 8:25 pm
  • Editorial Team
    Editorial Team added an answer The following works for me (let ((default-directory "/path/to/whereever/")) (shell "*shell1*")) May 13, 2026 at 8:25 pm
  • Editorial Team
    Editorial Team added an answer Unless you are referencing any DLL's included in .NET 3.0… May 13, 2026 at 8:25 pm

Related Questions

I want use html5's new tag to play a wav file (currently only supported
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I've got a string that has curly quotes in it. I'd like to replace
In order to apply a triggered animation to all ToolTip s in my app,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.