By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,628 Members | 1,747 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,628 IT Pros & Developers. It's quick & easy.

Javascript dropdown - dynamic width text, static length control

P: n/a
Hi All!

Has anyone seen an example of the following javascript powered control:
- a dropdown select menu
- the width of the control is set. Assume by "control" I mean the visible
part of the drop down before a mouse click occurs.
- the width of the list when selected is dynamic
- the width of the list can grow beyond the width of the control without
changing the width of the control.

Kind regards,

Rob
:)
Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Robert Mark Bram wrote:
Hi All!

Has anyone seen an example of the following javascript powered control:
- a dropdown select menu
Why do you need javascript when HTML accomplishes that?
- the width of the control is set. Assume by "control" I mean the visible
part of the drop down before a mouse click occurs.
That happens with plain HTML <select> elements. It assumes the width of
the widest/longest text in the options.
- the width of the list when selected is dynamic
dynamic depending on what?
- the width of the list can grow beyond the width of the control without
changing the width of the control.


How do you propose to change its width without changing its width?

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Jul 23 '05 #2

P: n/a
Hi Randy,

Thanks for the response. I will answer your questions as best I can, though
I feel you may not be satisfied with my attempt. :)
Has anyone seen an example of the following javascript powered control:
- a dropdown select menu


Why do you need javascript when HTML accomplishes that?
- the width of the list when selected is dynamic


dynamic depending on what?
- the width of the list can grow beyond the width of the control without
changing the width of the control.


How do you propose to change its width without changing its width?


I know how HTML select controls work and I am asking for something slightly
different.

The issue is that I need a select control whose width doesn't change: it
needs to have a static i.e. unchanging width that in most cases will be
narrower than the text contained in the widest option. This is something I
have done with VB on an Access form.

The design I have been asked to create involves a 'grid' of select controls,
all of which are the same size, no matter what text their options contain. I
understand if this sounds silly or unreasonable to you, but I am not asking
for design advice. I am only asking if anyone has seen a previous Javascript
example of this.
My idea here is to use Javascript to render the list when the user clicks
the drop down button, effectively meaning the <select> element would need to
be separate from the <option> elements. Most likely the solution would use a
text field and a graphic to 'fake' the drop down and render the list as a
layer.

Kind regards,

Rob
:)
Jul 23 '05 #3

P: n/a
Robert Mark Bram wrote:
Hi Randy,

Thanks for the response. I will answer your questions as best I can, though
I feel you may not be satisfied with my attempt. :)

Has anyone seen an example of the following javascript powered control:
- a dropdown select menu
Why do you need javascript when HTML accomplishes that?

- the width of the list when selected is dynamic


dynamic depending on what?

- the width of the list can grow beyond the width of the control without
changing the width of the control.


How do you propose to change its width without changing its width?

I know how HTML select controls work and I am asking for something slightly
different.


Fair enough.
The design I have been asked to create involves a 'grid' of select controls,
all of which are the same size, no matter what text their options contain. I
understand if this sounds silly or unreasonable to you, but I am not asking
for design advice. I am only asking if anyone has seen a previous Javascript
example of this.

My idea here is to use Javascript to render the list when the user clicks
the drop down button, effectively meaning the <select> element would need to
be separate from the <option> elements. Most likely the solution would use a
text field and a graphic to 'fake' the drop down and render the list as a
layer.


A text field wouldn't duplicate the complete functionality of a select,
but you already know that. With a select you can select one and then
arrow key through the selections. What you might be able to try instead
of rolling your own is look into possibly controlling the width (display
width) with CSS. Or, truncating the length of the select options .text

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.