473,399 Members | 3,919 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Align text in my drop down menu?

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
11 2442
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
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
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
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: KK | last post by:
Drop-down menus are the hottest thing since Wonder Bread but . . . 1. Alot of people put them in the they-look-nice-but-you-cant-code-them-right-so-they-always-look-messed-up category (a la...
10
by: Haines Brown | last post by:
I've implemented the horizontal drop down menu discussed recently in this newsgroup, and it works nicely under Galeon and Mozilla, but not IE 5.0. Here are the problems: Under IE 5.0, the...
4
by: Angie H. | last post by:
Anyone know how to create a drop down menu where the user can enter text also? If they do not want to choose an answer from the drop down menu, the users can just enter their own answers in the...
4
by: simon.cigoj | last post by:
I have an javascript made menu and some forms with the dropdown element. When the menu opens and scrolls down the drop down is displeyed over the menu and obscures the menu choices. I have this...
1
by: Kaland | last post by:
Do the search engines follow links that are within forms (like the drop-down menu) so that those pages are indexed? Here is the code for a sample drop-down menu that I created. <form><select...
1
by: Steve Richter | last post by:
I am using <div align=centerto center a horizontal menu on the page. Problem is the center align of the div is rippling down to the menu items and causing the text of the dynamic popup sub menu...
1
by: Ivann | last post by:
Hi All, I have a javascript/css menut that i have which i start when the html page loads. <script type="text/javascript">cssdropdown.startchrome("chromemenu")</ script> ***THIS IS IN THE...
0
by: Mark B | last post by:
I have an asp:Menu control in vertical drop-down mode, a portion as displayed: Can anyone tell me how to get Community correctly aligned with Support? Also how do I put a bit of a gap...
1
by: panos100m | last post by:
I cant put the text (register,members,find) in the center of the three buttons using Internet explorer... Any help will be much appreciated (html code below) <td class="ct"> <!-- menu...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.