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

Align text in my drop down menu?

P: n/a
Dan
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
Jul 21 '05 #1
Share this Question
Share on Google+
11 Replies


P: n/a
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(TheString & String(theLength, " "), 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=""yourValue"">" & sPadded & "</option>" &
vbCrLf
Next
%>
</select>
Ray at work
"Dan" <da***********@dbt.net> wrote in message
news:f0**************************@posting.google.c om...
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

Jul 21 '05 #2

P: n/a
Have you tried CSS ??

"Dan" <da***********@dbt.net> wrote in message
news:f0**************************@posting.google.c om...
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

---
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
Jul 21 '05 #3

P: n/a
Dan
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.Write(ld)%>
<%Response.Write(id)%>
<%Response.Write(appname)%>
<%Response.Write(transdesc)%>
<%Response.Write(referenceid)%>
<%Response.Write(transid)%>
<%Response.Write(transamount)%>
</option>
"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in message news:<#P**************@TK2MSFTNGP12.phx.gbl>...
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(TheString & String(theLength, " "), 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=""yourValue"">" & sPadded & "</option>" &
vbCrLf
Next
%>
</select>
Ray at work
"Dan" <da***********@dbt.net> wrote in message
news:f0**************************@posting.google.c om...
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

Jul 21 '05 #4

P: n/a
Dan
No, I have been trying styles but no luck yet.

"Hal Rosser" <hm******@bellsouth.net> wrote in message news:<0s********************@bignews3.bellsouth.ne t>...
Have you tried CSS ??

"Dan" <da***********@dbt.net> wrote in message
news:f0**************************@posting.google.c om...
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

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

Jul 21 '05 #5

P: n/a
Dan
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:<#P**************@TK2MSFTNGP12.phx.gbl>...
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(TheString & String(theLength, " "), 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=""yourValue"">" & sPadded & "</option>" &
vbCrLf
Next
%>
</select>
Ray at work
"Dan" <da***********@dbt.net> wrote in message
news:f0**************************@posting.google.c om...
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

Jul 21 '05 #6

P: n/a
Dan
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:<#P**************@TK2MSFTNGP12.phx.gbl>...
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(TheString & String(theLength, " "), 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=""yourValue"">" & sPadded & "</option>" &
vbCrLf
Next
%>
</select>
Ray at work
"Dan" <da***********@dbt.net> wrote in message
news:f0**************************@posting.google.c om...
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

Jul 21 '05 #7

P: n/a
da***********@dbt.net (Dan) wrote in message news:<f0**************************@posting.google. com>...
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.


Style Sheets. I.e.

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

This will make all select boxes 200 pixels wide.
Jul 21 '05 #8

P: n/a
If text is too small, make it bigger! If dropdown is then too narrow, make
it wider!

Ray at work
"Dan" <da***********@dbt.net> wrote in message
news:f0**************************@posting.google.c om...
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.


Jul 21 '05 #9

P: n/a
Dan wrote:
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.


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.
Jul 21 '05 #10

P: n/a
Dan
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" <GT**********@spammotel.com> wrote in message news:<eI**************@TK2MSFTNGP15.phx.gbl>...
Dan wrote:
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.


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.

Jul 21 '05 #11

P: n/a
Dan
Thank you Larry
-Dan
la**********@yahoo.com (Larry Bud) wrote in message news:<5d*************************@posting.google.c om>...
da***********@dbt.net (Dan) wrote in message news:<f0**************************@posting.google. com>...
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.


Style Sheets. I.e.

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

This will make all select boxes 200 pixels wide.

Jul 21 '05 #12

This discussion thread is closed

Replies have been disabled for this discussion.