Align text in my drop down menu?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dan

    Align text in my drop down menu?

    Hello all,
    I am getting records from a db and displaying the records to the user
    through a drop down menu in an asp page.

    Each record has 6 fields and I need to display them all to the user in
    the drop down.

    The problem is that the fields contain values of all different lengths
    and the columns are not aligned.

    I tried to align by calculating the len for each field and padding but
    the characters are different widths and this does not work.

    Can someone tell me how to align the text in the drop down? I would
    appreciate any ideas out there.

    Thank you much for your help,
    -Dan
  • Ray Costanzo [MVP]

    #2
    Re: Align text in my drop down menu?

    You could pad your values to a minimum length with  's and use a
    fixed-width font like so:



    <%
    Function PadTo(theString , theLength)
    '''Take a string and a mininum length
    '''for the string, pads the string with
    '''&nbsp;'s, and then returns the string
    '''at theLength specified
    PadTo = Replace(Left(Th eString & String(theLengt h, " "), theLength), "
    ", "&nbsp;")
    End Function

    Dim aData(5,2)

    aData(0,0) = "Ray"
    aData(1,0) = "Costanzo"
    aData(2,0) = "123 Some RD"
    aData(3,0) = "Somecity"
    aData(4,0) = "ZZ"
    aData(5,0) = "99999"
    aData(0,1) = "Joe"
    aData(1,1) = "Smith"
    aData(2,1) = "987 Other Rd"
    aData(3,1) = "Another City"
    aData(4,1) = "AA"
    aData(5,1) = "88888"
    aData(0,2) = "Betty"
    aData(1,2) = "Jones"
    aData(2,2) = "456 Main St"
    aData(3,2) = "Anytown"
    aData(4,2) = "QQ"
    aData(5,2) = "77777"

    %>


    <select style="font-family: monospace;">
    <%
    For i = 0 To UBound(aData, 2)
    sPadded = PadTo(aData(0,i ), 10) & PadTo(aData(1,i ), 20) &
    PadTo(aData(2,i ), 25) & PadTo(aData(3,i ), 25) & PadTo(aData(4,i ), 4) &
    PadTo(aData(5,i ), 10)
    Response.Write "<option value=""yourVal ue"">" & sPadded & "</option>" &
    vbCrLf
    Next
    %>
    </select>


    Ray at work


    "Dan" <danieloconnor@ dbt.net> wrote in message
    news:f03dc8e4.0 410261335.23c41 6fe@posting.goo gle.com...[color=blue]
    > Hello all,
    > I am getting records from a db and displaying the records to the user
    > through a drop down menu in an asp page.
    >
    > Each record has 6 fields and I need to display them all to the user in
    > the drop down.
    >
    > The problem is that the fields contain values of all different lengths
    > and the columns are not aligned.
    >
    > I tried to align by calculating the len for each field and padding but
    > the characters are different widths and this does not work.
    >
    > Can someone tell me how to align the text in the drop down? I would
    > appreciate any ideas out there.
    >
    > Thank you much for your help,
    > -Dan[/color]


    Comment

    • Hal Rosser

      #3
      Re: Align text in my drop down menu?

      Have you tried CSS ??

      "Dan" <danieloconnor@ dbt.net> wrote in message
      news:f03dc8e4.0 410261335.23c41 6fe@posting.goo gle.com...[color=blue]
      > Hello all,
      > I am getting records from a db and displaying the records to the user
      > through a drop down menu in an asp page.
      >
      > Each record has 6 fields and I need to display them all to the user in
      > the drop down.
      >
      > The problem is that the fields contain values of all different lengths
      > and the columns are not aligned.
      >
      > I tried to align by calculating the len for each field and padding but
      > the characters are different widths and this does not work.
      >
      > Can someone tell me how to align the text in the drop down? I would
      > appreciate any ideas out there.
      >
      > Thank you much for your help,
      > -Dan[/color]


      ---
      Outgoing mail is certified Virus Free.
      Checked by AVG anti-virus system (http://www.grisoft.com).
      Version: 6.0.781 / Virus Database: 527 - Release Date: 10/21/2004


      Comment

      • Dan

        #4
        Re: Align text in my drop down menu?

        Thank you Ray. I tried exactly your suggestion as I mentioned in my
        previous posting but the problem is that the strings may be the same
        length but the widths are different on the html page.

        Anyway I am posting the problem code below for clerification. Thank
        you.

        <option><B>
        <%Response.Writ e(ld)%>
        <%Response.Writ e(id)%>
        <%Response.Writ e(appname)%>
        <%Response.Writ e(transdesc)%>
        <%Response.Writ e(referenceid)% >
        <%Response.Writ e(transid)%>
        <%Response.Writ e(transamount)% >
        </option>


        "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in message news:<#Pifoj6uE HA.1988@TK2MSFT NGP12.phx.gbl>. ..[color=blue]
        > You could pad your values to a minimum length with &nbsp;'s and use a
        > fixed-width font like so:
        >
        >
        >
        > <%
        > Function PadTo(theString , theLength)
        > '''Take a string and a mininum length
        > '''for the string, pads the string with
        > '''&nbsp;'s, and then returns the string
        > '''at theLength specified
        > PadTo = Replace(Left(Th eString & String(theLengt h, " "), theLength), "
        > ", "&nbsp;")
        > End Function
        >
        > Dim aData(5,2)
        >
        > aData(0,0) = "Ray"
        > aData(1,0) = "Costanzo"
        > aData(2,0) = "123 Some RD"
        > aData(3,0) = "Somecity"
        > aData(4,0) = "ZZ"
        > aData(5,0) = "99999"
        > aData(0,1) = "Joe"
        > aData(1,1) = "Smith"
        > aData(2,1) = "987 Other Rd"
        > aData(3,1) = "Another City"
        > aData(4,1) = "AA"
        > aData(5,1) = "88888"
        > aData(0,2) = "Betty"
        > aData(1,2) = "Jones"
        > aData(2,2) = "456 Main St"
        > aData(3,2) = "Anytown"
        > aData(4,2) = "QQ"
        > aData(5,2) = "77777"
        >
        > %>
        >
        >
        > <select style="font-family: monospace;">
        > <%
        > For i = 0 To UBound(aData, 2)
        > sPadded = PadTo(aData(0,i ), 10) & PadTo(aData(1,i ), 20) &
        > PadTo(aData(2,i ), 25) & PadTo(aData(3,i ), 25) & PadTo(aData(4,i ), 4) &
        > PadTo(aData(5,i ), 10)
        > Response.Write "<option value=""yourVal ue"">" & sPadded & "</option>" &
        > vbCrLf
        > Next
        > %>
        > </select>
        >
        >
        > Ray at work
        >
        >
        > "Dan" <danieloconnor@ dbt.net> wrote in message
        > news:f03dc8e4.0 410261335.23c41 6fe@posting.goo gle.com...[color=green]
        > > Hello all,
        > > I am getting records from a db and displaying the records to the user
        > > through a drop down menu in an asp page.
        > >
        > > Each record has 6 fields and I need to display them all to the user in
        > > the drop down.
        > >
        > > The problem is that the fields contain values of all different lengths
        > > and the columns are not aligned.
        > >
        > > I tried to align by calculating the len for each field and padding but
        > > the characters are different widths and this does not work.
        > >
        > > Can someone tell me how to align the text in the drop down? I would
        > > appreciate any ideas out there.
        > >
        > > Thank you much for your help,
        > > -Dan[/color][/color]

        Comment

        • Dan

          #5
          Re: Align text in my drop down menu?

          No, I have been trying styles but no luck yet.

          "Hal Rosser" <hmrosser@bells outh.net> wrote in message news:<0sFfd.211 793$as2.89204@b ignews3.bellsou th.net>...[color=blue]
          > Have you tried CSS ??
          >
          > "Dan" <danieloconnor@ dbt.net> wrote in message
          > news:f03dc8e4.0 410261335.23c41 6fe@posting.goo gle.com...[color=green]
          > > Hello all,
          > > I am getting records from a db and displaying the records to the user
          > > through a drop down menu in an asp page.
          > >
          > > Each record has 6 fields and I need to display them all to the user in
          > > the drop down.
          > >
          > > The problem is that the fields contain values of all different lengths
          > > and the columns are not aligned.
          > >
          > > I tried to align by calculating the len for each field and padding but
          > > the characters are different widths and this does not work.
          > >
          > > Can someone tell me how to align the text in the drop down? I would
          > > appreciate any ideas out there.
          > >
          > > Thank you much for your help,
          > > -Dan[/color]
          >
          >
          > ---
          > Outgoing mail is certified Virus Free.
          > Checked by AVG anti-virus system (http://www.grisoft.com).
          > Version: 6.0.781 / Virus Database: 527 - Release Date: 10/21/2004[/color]

          Comment

          • Dan

            #6
            Re: Align text in my drop down menu?

            Hello again Ray. I guess I did not read carefully before posting my
            last message. I see that you suggest using a fixed width font as you
            show below.

            It sounds like you have experience with this. I was going to try
            this initially but I read negatives against doing this in other
            arcticles stating I was not very readable.

            I will try this and let you know. Thank you for your help,
            -Dan




            "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in message news:<#Pifoj6uE HA.1988@TK2MSFT NGP12.phx.gbl>. ..[color=blue]
            > You could pad your values to a minimum length with &nbsp;'s and use a
            > fixed-width font like so:
            >
            >
            >
            > <%
            > Function PadTo(theString , theLength)
            > '''Take a string and a mininum length
            > '''for the string, pads the string with
            > '''&nbsp;'s, and then returns the string
            > '''at theLength specified
            > PadTo = Replace(Left(Th eString & String(theLengt h, " "), theLength), "
            > ", "&nbsp;")
            > End Function
            >
            > Dim aData(5,2)
            >
            > aData(0,0) = "Ray"
            > aData(1,0) = "Costanzo"
            > aData(2,0) = "123 Some RD"
            > aData(3,0) = "Somecity"
            > aData(4,0) = "ZZ"
            > aData(5,0) = "99999"
            > aData(0,1) = "Joe"
            > aData(1,1) = "Smith"
            > aData(2,1) = "987 Other Rd"
            > aData(3,1) = "Another City"
            > aData(4,1) = "AA"
            > aData(5,1) = "88888"
            > aData(0,2) = "Betty"
            > aData(1,2) = "Jones"
            > aData(2,2) = "456 Main St"
            > aData(3,2) = "Anytown"
            > aData(4,2) = "QQ"
            > aData(5,2) = "77777"
            >
            > %>
            >
            >
            > <select style="font-family: monospace;">
            > <%
            > For i = 0 To UBound(aData, 2)
            > sPadded = PadTo(aData(0,i ), 10) & PadTo(aData(1,i ), 20) &
            > PadTo(aData(2,i ), 25) & PadTo(aData(3,i ), 25) & PadTo(aData(4,i ), 4) &
            > PadTo(aData(5,i ), 10)
            > Response.Write "<option value=""yourVal ue"">" & sPadded & "</option>" &
            > vbCrLf
            > Next
            > %>
            > </select>
            >
            >
            > Ray at work
            >
            >
            > "Dan" <danieloconnor@ dbt.net> wrote in message
            > news:f03dc8e4.0 410261335.23c41 6fe@posting.goo gle.com...[color=green]
            > > Hello all,
            > > I am getting records from a db and displaying the records to the user
            > > through a drop down menu in an asp page.
            > >
            > > Each record has 6 fields and I need to display them all to the user in
            > > the drop down.
            > >
            > > The problem is that the fields contain values of all different lengths
            > > and the columns are not aligned.
            > >
            > > I tried to align by calculating the len for each field and padding but
            > > the characters are different widths and this does not work.
            > >
            > > Can someone tell me how to align the text in the drop down? I would
            > > appreciate any ideas out there.
            > >
            > > Thank you much for your help,
            > > -Dan[/color][/color]

            Comment

            • Dan

              #7
              Re: Align text in my drop down menu?

              Hello once again Ray. This did work however it is very hard to read
              with the xx-small font size that I am using. It does look good with
              x-small but that is still too large to fit my data on the page.

              Any suggestions would be welcome.

              Thank you much,
              -Dan


              "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in message news:<#Pifoj6uE HA.1988@TK2MSFT NGP12.phx.gbl>. ..[color=blue]
              > You could pad your values to a minimum length with &nbsp;'s and use a
              > fixed-width font like so:
              >
              >
              >
              > <%
              > Function PadTo(theString , theLength)
              > '''Take a string and a mininum length
              > '''for the string, pads the string with
              > '''&nbsp;'s, and then returns the string
              > '''at theLength specified
              > PadTo = Replace(Left(Th eString & String(theLengt h, " "), theLength), "
              > ", "&nbsp;")
              > End Function
              >
              > Dim aData(5,2)
              >
              > aData(0,0) = "Ray"
              > aData(1,0) = "Costanzo"
              > aData(2,0) = "123 Some RD"
              > aData(3,0) = "Somecity"
              > aData(4,0) = "ZZ"
              > aData(5,0) = "99999"
              > aData(0,1) = "Joe"
              > aData(1,1) = "Smith"
              > aData(2,1) = "987 Other Rd"
              > aData(3,1) = "Another City"
              > aData(4,1) = "AA"
              > aData(5,1) = "88888"
              > aData(0,2) = "Betty"
              > aData(1,2) = "Jones"
              > aData(2,2) = "456 Main St"
              > aData(3,2) = "Anytown"
              > aData(4,2) = "QQ"
              > aData(5,2) = "77777"
              >
              > %>
              >
              >
              > <select style="font-family: monospace;">
              > <%
              > For i = 0 To UBound(aData, 2)
              > sPadded = PadTo(aData(0,i ), 10) & PadTo(aData(1,i ), 20) &
              > PadTo(aData(2,i ), 25) & PadTo(aData(3,i ), 25) & PadTo(aData(4,i ), 4) &
              > PadTo(aData(5,i ), 10)
              > Response.Write "<option value=""yourVal ue"">" & sPadded & "</option>" &
              > vbCrLf
              > Next
              > %>
              > </select>
              >
              >
              > Ray at work
              >
              >
              > "Dan" <danieloconnor@ dbt.net> wrote in message
              > news:f03dc8e4.0 410261335.23c41 6fe@posting.goo gle.com...[color=green]
              > > Hello all,
              > > I am getting records from a db and displaying the records to the user
              > > through a drop down menu in an asp page.
              > >
              > > Each record has 6 fields and I need to display them all to the user in
              > > the drop down.
              > >
              > > The problem is that the fields contain values of all different lengths
              > > and the columns are not aligned.
              > >
              > > I tried to align by calculating the len for each field and padding but
              > > the characters are different widths and this does not work.
              > >
              > > Can someone tell me how to align the text in the drop down? I would
              > > appreciate any ideas out there.
              > >
              > > Thank you much for your help,
              > > -Dan[/color][/color]

              Comment

              • Larry Bud

                #8
                Re: Align text in my drop down menu?

                danieloconnor@d bt.net (Dan) wrote in message news:<f03dc8e4. 0410261335.23c4 16fe@posting.go ogle.com>...[color=blue]
                > Hello all,
                > I am getting records from a db and displaying the records to the user
                > through a drop down menu in an asp page.
                >
                > Each record has 6 fields and I need to display them all to the user in
                > the drop down.
                >
                > The problem is that the fields contain values of all different lengths
                > and the columns are not aligned.
                >
                > I tried to align by calculating the len for each field and padding but
                > the characters are different widths and this does not work.
                >
                > Can someone tell me how to align the text in the drop down? I would
                > appreciate any ideas out there.[/color]

                Style Sheets. I.e.

                <style>
                <!--
                select { width: 200 }
                -->
                </style>

                This will make all select boxes 200 pixels wide.

                Comment

                • Ray Costanzo [MVP]

                  #9
                  Re: Align text in my drop down menu?

                  If text is too small, make it bigger! If dropdown is then too narrow, make
                  it wider!

                  Ray at work


                  "Dan" <danieloconnor@ dbt.net> wrote in message
                  news:f03dc8e4.0 410270848.1a2d6 100@posting.goo gle.com...[color=blue]
                  > Hello once again Ray. This did work however it is very hard to read
                  > with the xx-small font size that I am using. It does look good with
                  > x-small but that is still too large to fit my data on the page.
                  >
                  > Any suggestions would be welcome.
                  >[/color]

                  Comment

                  • Dave Anderson

                    #10
                    Re: Align text in my drop down menu?

                    Dan wrote:[color=blue]
                    > I am getting records from a db and displaying the records to the user
                    > through a drop down menu in an asp page.
                    >
                    > Each record has 6 fields and I need to display them all to the user in
                    > the drop down.[/color]

                    I have a colleague who feels the need to do this, and I have spent a bit of
                    time solving his resulting problems. My advice is to stop now, before you
                    waste any more of your time. You will NEVER succeed in creating a useful,
                    reliable, cross-browser implementation* *, in my opinion.

                    For one thing, take a look at the problem of padding. How does your browser
                    render this? How does every other browser render it? (answer:you can't know)

                    <OPTION>1 2 3 4 5</OPTION>
                    <OPTION>6 7 8</OPTION>

                    There is already an appropriate tool for displaying tabular data: a table.
                    If you feel the need to bundle a bunch of data elements together with a
                    single SELECT element, why not have a handful of dependent fields that are
                    updated every time the SELECT element is changed? It certainly would give
                    you more display flexibility...



                    **My colleague, for example, has found that the multiple "columns" in his
                    SELECT element need to be positioned below static column headers. As he has
                    no control over the OS or even the browser (or whether the user prefers the
                    classic Windows interface over the XP interface), the rendering of the
                    SELECT element can never be guaranteed to line up precisely with the textual
                    "column headers", no matter what font selection he chooses. That is but one
                    of his problems.


                    --
                    Dave Anderson

                    Unsolicited commercial email will be read at a cost of $500 per message. Use
                    of this email address implies consent to these terms. Please do not contact
                    me directly or ask me to contact you directly for assistance. If your
                    question is worth asking, it's worth posting.


                    Comment

                    • Dan

                      #11
                      Re: Align text in my drop down menu?

                      Thank you Dave for your suggestions. The reason I am bunching fields
                      together is to give the user more information to make their selection.
                      In this case they are crediting the customer for a particular record.
                      I already have the information available in a table if the user wants
                      to see the log but If we can give them the functionality of selecting
                      the record and the ability to credit for the record in one step the
                      user would be more happy.

                      I have found what you have pointed out to be accurate as far as I can
                      see and I have found a fixed width font that I can live with. I am
                      also entering the column headings as the first selection in the drop
                      down. I don't really like this but I have not come up with any other
                      options at this time.

                      I wonder if there is not a java script out there that would take the
                      data and format for me but I guess that is something I can look at in
                      the future.

                      Thanks again for your help Dave,
                      -Dan


                      "Dave Anderson" <GTSPXOESSGOQ@s pammotel.com> wrote in message news:<eIseUvFvE HA.4048@TK2MSFT NGP15.phx.gbl>. ..[color=blue]
                      > Dan wrote:[color=green]
                      > > I am getting records from a db and displaying the records to the user
                      > > through a drop down menu in an asp page.
                      > >
                      > > Each record has 6 fields and I need to display them all to the user in
                      > > the drop down.[/color]
                      >
                      > I have a colleague who feels the need to do this, and I have spent a bit of
                      > time solving his resulting problems. My advice is to stop now, before you
                      > waste any more of your time. You will NEVER succeed in creating a useful,
                      > reliable, cross-browser implementation* *, in my opinion.
                      >
                      > For one thing, take a look at the problem of padding. How does your browser
                      > render this? How does every other browser render it? (answer:you can't know)
                      >
                      > <OPTION>1 2 3 4 5</OPTION>
                      > <OPTION>6 7 8</OPTION>
                      >
                      > There is already an appropriate tool for displaying tabular data: a table.
                      > If you feel the need to bundle a bunch of data elements together with a
                      > single SELECT element, why not have a handful of dependent fields that are
                      > updated every time the SELECT element is changed? It certainly would give
                      > you more display flexibility...
                      >
                      >
                      >
                      > **My colleague, for example, has found that the multiple "columns" in his
                      > SELECT element need to be positioned below static column headers. As he has
                      > no control over the OS or even the browser (or whether the user prefers the
                      > classic Windows interface over the XP interface), the rendering of the
                      > SELECT element can never be guaranteed to line up precisely with the textual
                      > "column headers", no matter what font selection he chooses. That is but one
                      > of his problems.[/color]

                      Comment

                      • Dan

                        #12
                        Re: Align text in my drop down menu?

                        Thank you Larry
                        -Dan


                        larrybud2002@ya hoo.com (Larry Bud) wrote in message news:<5db363e0. 0410270851.ed4f 887@posting.goo gle.com>...[color=blue]
                        > danieloconnor@d bt.net (Dan) wrote in message news:<f03dc8e4. 0410261335.23c4 16fe@posting.go ogle.com>...[color=green]
                        > > Hello all,
                        > > I am getting records from a db and displaying the records to the user
                        > > through a drop down menu in an asp page.
                        > >
                        > > Each record has 6 fields and I need to display them all to the user in
                        > > the drop down.
                        > >
                        > > The problem is that the fields contain values of all different lengths
                        > > and the columns are not aligned.
                        > >
                        > > I tried to align by calculating the len for each field and padding but
                        > > the characters are different widths and this does not work.
                        > >
                        > > Can someone tell me how to align the text in the drop down? I would
                        > > appreciate any ideas out there.[/color]
                        >
                        > Style Sheets. I.e.
                        >
                        > <style>
                        > <!--
                        > select { width: 200 }
                        > -->
                        > </style>
                        >
                        > This will make all select boxes 200 pixels wide.[/color]

                        Comment

                        Working...