James,

Thanks for the response. I don't know why I didn't see it before, but
your comment about the conditional check got me thinking. I did try
  $this.attr("selected", "selected");

and that works just as well as my original, but the conditional is
where my problem was. FF understood the 'textContent' attribute, but
IE6&7 only understood 'text'. Honestly, when I was looking at the
thing originally in FF, I just didn't see 'text' I saw only
'textContent' so that's what I used. Thankfully though FF and IE6&7
understand $this.attr("text"), so I'm all good now.

Thanks,
Chris

On Feb 26, 3:32 pm, James <james.gp....@gmail.com> wrote:
> I'm not sure about the:
>     if($this.attr("textContent") == PublishTo)
> part. It sounds very custom. Provided this conditional check is
> working correctly, how about trying:
>     $this.attr("selected", "selected") ;
> to set the value.
>
> Or if you can get the actual options value, you can set the value of
> the select drop-down:
> $("select").val(1);
>
> On Feb 26, 11:24 am, Chris Jordan <chris.s.jor...@gmail.com> wrote:
>
> > I just realized I may need to explain a little further.
>
> > I've got a table on the same page. Clicking on a record in that table
> > populates a small form on the page with the information from that
> > record. The text and check boxes are easy enough to populate, but
> > telling the select box which of it's options is now selected as a
> > result of that user click is a little harder it seems.
>
> > The code snippet in my original post fires when a user clicks on a
> > record in the table, and in FireFox 3.0.6 it works just fine, but in
> > IE6 and IE7 it fails. I should also probably mention that I'm using
> > jquery 1.2.6 packed.
>
> > Thanks,
> > Chris
>
> > On Feb 26, 3:11 pm, Chris Jordan <chris.s.jor...@gmail.com> wrote:
>
> > > Hi folks,
>
> > > I'm trying to manipulate which item in a select box is selected using
> > > jQuery. The following code snippet works great in FF but fails miserably 
> > > in
> > > IE6 and IE7
>
> > >  // select the publish to option
> > > $("#PublishToID > option").each(function(){
> > >     $this = $(this);
> > >     if($this.attr("textContent") == PublishTo){
> > >         $this.attr("selected", true)
> > >     }
>
> > > });
>
> > > Given that I have a select box that looks like this:
>
> > > <select name="PublishTo" id="PublishToID">
> > >     <option value="3">Some Page Title</option>
> > >     <option value="4">Some Other Page Title</option>
> > >     <option value="5">Page 5</option>
> > >     <option value="1">Page 1</option>
> > >     <option value="2">Page 2</option>
> > > </select>
>
> > > --http://cjordan.us

Reply via email to