Charlie, you're adding options to a select element and then attempting to
get its width immediately, right? And when you do this the width in IE is
not correct, right?

A quick test would be to add a click event to your page that alerts the
width of the select element. I bet this will return the correct width.

$('#box-width').click(function(){ alert( $("#select-thing").width() ) });

For the long-term solution, try adding a timeout to your code that accesses
the width of your select element. The timeout delay can be 0ms (basically
just pushing it to the end of the cue). I'm pretty sure this will work:

setTimeout( function(){ alert( $("#select-thing").width() ) }, 0 );

Basically, what I suspect is happening is that you're adding the options,
but not giving the user interface enough time to update. Some form elements
(like radio buttons and select boxes) take time (very little time) to
update... and you won't be able to access the new values until that's
happened.

Good luck,
Brian.

On 10/31/07, charlie <[EMAIL PROTECTED]> wrote:
>
>
> I've bugged it here: http://jquery.com/plugins/node/787 and here:
> http://dev.jquery.com/ticket/1870 but I'm wondering if any one has any
> ideas for a workaround (other than switching browsers
> unfortunately) .  Basically, in IE6 the width() on a select box (or
> it's surrounding div/span) is not updated when wide options are added
> to the select.  It works great in Firefox, but that doesn't help me
> too much.
>
> The basic problem is this.  I have a row of select boxes that need to
> be of minimum widths (ie. no defined width). Then at the end of this
> row there is a "subtotal" column, all of which works fine.  Except
> that below these rows I'd like to have a total column that is aligned
> with the subtotal columns.
>
> All of this would be trivial of course if I used tables, but for
> various reasons the layout must remain div based.  Any suggestions?
>
>

Reply via email to