Forum Moderators: open

Message Too Old, No Replies

How to dynamically change the size of a <select> list?

Works in all browsers except Safari...

         

MichaelBluejay

6:55 pm on Aug 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



This works in IE and Firefox, but not Safari:

<a href="#" onclick="document.theform.thefield.size=8">expand list</a>

In Safari, nothing happens when I click.

Any ideas on how I make it work in Safari?

Rambo Tribble

1:54 am on Aug 13, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have you tried the W3C DOM method of element_reference.setAttribute('attributeName',value)?

MichaelBluejay

9:12 am on Aug 13, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Wasn't familiar with that syntax. But I tried it and I have the same problem: Works in FireFox, doesn't work in Safari 2.0.4 (latest version).

Rambo Tribble

1:55 pm on Aug 13, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That would suggest that control of this attribute on an existing element has not been implemented in the Safari/Konqueror DOM API. Indeed, my experiments show that while the associated get method has been implemented, the set method has not, in this context.

Not much you could do other than to try removing the node altogether and then replacing it with the new specification. While a tedious approach, my preliminary tests indicate that in the context of a new element's creation, the setAttribute method does work to assign a size to the new select, at least on Konqueror.

[edited by: Rambo_Tribble at 1:56 pm (utc) on Aug. 13, 2006]

Rambo Tribble

2:08 pm on Aug 13, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hold the phone. Additional testing at the RTLabs facilities has demonstrated that the problem is with K/S not redrawing the element after the size modification. Working day and night our elite technicians have determined that if you set the attribute, then set element_reference.style.display='none', followed by element_reference.style.display='block' the element will reappear in its new and gloriously modified condition. Rather reminds me of Alice's cat, though with options rather than teeth.

MichaelBluejay

6:50 pm on Aug 13, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Yes, this works perfectly, thanks! Please give your hardworking techs a cookie.

Rambo Tribble

3:05 am on Aug 14, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




Please give your hardworking techs a cookie.

Well, I would, but cookies make them giddy (it's the sugar, you know). Nothing worse, really, than a giddy technician. Keep 'em sullen, but not rebellious, that's what I always say. (An actual approximate quote from a Burroughs executive in the '60's, regarding customers, vis-a-vis service. Whatever happened to Burroughs, anyway? [They went on the skids and joined Sperry to form Unisys.])