The `Option` constructor is provided by the browser and returns an
HTMLOptionElement instance; since IE6 and IE7 don't allow prototypical
extensions to these things[1], you have to run it through `$` (or
`Element.extend`) to extend the element:

function optionAdder(s) {
  var optIdx = $('mySelect').options.length;
  $('mySelect').options[optIdx] = $(new Option(s.text, s.val)); // <==
Change is here
  $('mySelect').options[optIdx].store("meta", s.meta);

In contrast to `Option`, the `Element` constructor is provided by
Prototype and does this for you automatically.

[1] http://prototypejs.org/learn/extensions

T.J. Crowder
Independent Software Consultant
tj / crowder software / com

On May 28, 4:30 pm, blechler <lech...@gmail.com> wrote:
> Whilst flogging the horse that should be dead (IE7); I discovered that
> I was unable to use Element.store on the options within a select:
> function optionAdder(s) {
>   var optIdx = $('mySelect').options.length;
>   $('mySelect').options[optIdx] = new Option(s.text, s.val);
>   $('mySelect').options[optIdx].store("meta", s.meta);       //<----
> Object doesn't support this property or method
> }
> The above function works in IE8.  This next function, on the other
> hand, does work in IE7:
> function optionAdder(s) {
>   $('mySelect').appendChild(new Element('option', {"value":s.val,
> "meta":s.meta}).update(s.text));
> }
> In this case I use readAttribute instead of the retrieve method.  Can
> anyone offer insight as to why store doesn't work?

You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to