473,246 Members | 1,956 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,246 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 2429
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: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.