Hi -
I'm experiencing the same problem with IE6 where I get an error "Could
not set the selected property. Unspecified error" when executing the
code:
$("option:first", "#my_select").attr("selected",true);
OR $("option:first", "#my_select").attr("selected","selected");
OR $("#my_select").children("[EMAIL PROTECTED]"+my_value+"]").attr("selected",
"selected");

It seems that there is a bug with IE6 when trying to apply .attr
after .children -
It works perfectly with IE7 / Firefox / Safari.

Thanx for your help - Ben


On May 25, 9:16 am, "Rob Desbois" <[EMAIL PROTECTED]> wrote:
> Rob,
>
> The function $.each is *the* jQuery function - $ refers to the global jQuery
> object, which has a member function each(), hence that is how I refer to it.
> You wouldn't need to use the $ if a jQuery object was assigned to something
> else, e.g.
>
> > var elements = $("...");
> > elements.each(function() {...});
>
> If you only need to use the element which matches that value requirement
> then you can include that attribute in the selector instead of iterating
> over the set:
>
> function test(value)
>
> > {
> >    $("#smsUserPrice [EMAIL PROTECTED]"+value+"]").attr("selected", true);
> > }
>
> So you then just need to pass the value of the option to select into the
> function.
>
> --rob
>
> On 5/24/07, RobG <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > On May 25, 1:29 am, "Rob Desbois" <[EMAIL PROTECTED]> wrote:
> > > Oh yes, sorry I forgot the ); after the function passed to $.each().
> > > Corrected (and tested!) version is below:
>
> > It seems to me that the only jQuery function necessary is .each,
> > subsequent use of $ is unnecessary.
>
> > If the intention is to select only one option (i.e. it is a single
> > select) then the function should exit once that occurs - the following
> > is a shorter version.    I'm new to jQuery, can you show me how to get
> > out of the loop once the correct option is found?
>
> > function test() {
> >   $("#smsUserPrice option").each(function()  {
> >     if ( this.value == "z" ) {
> >       this.selected = true;
>
> >       // stop .each loop here... how?
>
> >     }
> >   }
> > }
>
> > --
> > Rob
>
> --
> Rob Desbois
> Eml: [EMAIL PROTECTED]
> Tel: 01452 760631
> Mob: 07946 705987
> "There's a whale there's a whale there's a whale fish" he cried, and the
> whale was in full view.
> ...Then ooh welcome. Ahhh. Ooh mug welcome.

Reply via email to