Align text in my drop down menu?

D

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
 
R

Ray Costanzo [MVP]

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
 
H

Hal Rosser

Have you tried CSS ??

Dan said:
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
 
D

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

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
 
D

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
 
L

Larry Bud

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

Ray Costanzo [MVP]

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

Ray at work
 
D

Dave Anderson

Dan said:
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.
 
D

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,216
Latest member
topweb3twitterchannels

Latest Threads

Top