Javascript dropdown - dynamic width text, static length control

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Robert Mark Bram

    Javascript dropdown - dynamic width text, static length control

    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
    :)


  • Randy Webb

    #2
    Re: Javascript dropdown - dynamic width text, static length control

    Robert Mark Bram wrote:[color=blue]
    > Hi All!
    >
    > Has anyone seen an example of the following javascript powered control:
    > - a dropdown select menu[/color]

    Why do you need javascript when HTML accomplishes that?
    [color=blue]
    > - the width of the control is set. Assume by "control" I mean the visible
    > part of the drop down before a mouse click occurs.[/color]

    That happens with plain HTML <select> elements. It assumes the width of
    the widest/longest text in the options.
    [color=blue]
    > - the width of the list when selected is dynamic[/color]

    dynamic depending on what?
    [color=blue]
    > - the width of the list can grow beyond the width of the control without
    > changing the width of the control.[/color]

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

    --
    Randy
    comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly

    Comment

    • Robert Mark Bram

      #3
      Re: Javascript dropdown - dynamic width text, static length control

      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. :)
      [color=blue][color=green]
      >> Has anyone seen an example of the following javascript powered control:
      >> - a dropdown select menu[/color]
      >
      > Why do you need javascript when HTML accomplishes that?
      >[color=green]
      >> - the width of the list when selected is dynamic[/color]
      >
      > dynamic depending on what?
      >[color=green]
      >> - the width of the list can grow beyond the width of the control without
      >> changing the width of the control.[/color]
      >
      > How do you propose to change its width without changing its width?
      >[/color]

      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
      :)


      Comment

      • Randy Webb

        #4
        Re: Javascript dropdown - dynamic width text, static length control

        Robert Mark Bram wrote:
        [color=blue]
        > 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. :)
        >
        >[color=green][color=darkred]
        >>>Has anyone seen an example of the following javascript powered control:
        >>>- a dropdown select menu[/color]
        >>
        >>Why do you need javascript when HTML accomplishes that?
        >>
        >>[color=darkred]
        >>>- the width of the list when selected is dynamic[/color]
        >>
        >>dynamic depending on what?
        >>
        >>[color=darkred]
        >>>- the width of the list can grow beyond the width of the control without
        >>>changing the width of the control.[/color]
        >>
        >>How do you propose to change its width without changing its width?
        >>[/color]
        >
        >
        > I know how HTML select controls work and I am asking for something slightly
        > different.[/color]

        Fair enough.
        [color=blue]
        > 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.[/color]


        [color=blue]
        > 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.[/color]

        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.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly

        Comment

        Working...