GeeCON Prague 2014*
The moose likes HTML, CSS and JavaScript and the fly likes Alignment on Decimal Number Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Alignment on Decimal Number" Watch "Alignment on Decimal Number" New topic
Author

Alignment on Decimal Number

Anurag Mishra
Ranch Hand

Joined: Jun 16, 2003
Posts: 121
Hi,
Can anyone just tell me how I can align the Number based on Decimal point.
I mean suppose I have numbers as
1.3, 02.09, 102.08, 1008.009 etc
I want to Align all these in HTML table as all values muct be aligned with decimal like.....
1.3
02.09
102.08
1008.009

I mean decimal must come in a straight line.
thanks for all your help.
Anurag Mishra
Ranch Hand

Joined: Jun 16, 2003
Posts: 121
Hi All Sorry but after posting i noticed values are not aligned with Decimal
pls assume its aligned around decimal.
I am trying to post it again
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
if you want to do it you are probably going to have to split all of the numbers by the deciaml and place them in two table cells with the one being right aligned and the other left aligned
Or you are going to have to add characters that match the background color in front of the strings so they line up correctly like you just added the *'s
Eric
Tom Blough
Ranch Hand

Joined: Jul 31, 2003
Posts: 263
Originally posted by Eric Pascarello:
Or you are going to have to add characters that match the background color in front of the strings so they line up correctly like you just added the *'s

I think the first choice is the way to go. Adding characters to attempt to line the items up will not work very well since browsers usually use proportionally spaced fonts. You'd have to enclose the numbers in code tags or use a fixed width font like Courier to get them to display correctly.
Tom Blough


Tom Blough<br /> <blockquote><font size="1" face="Verdana, Arial">quote:</font><hr>Cum catapultae proscriptae erunt tum soli proscripti catapultas habebunt.<hr></blockquote>
Anurag Mishra
Ranch Hand

Joined: Jun 16, 2003
Posts: 121
Hi Eric n Tom,
Thanks for your reply,
I am gettinfg these values from database then how I can seperate them and put in two different cells?
Can you give me some small example Eric or just an Idea.
thanks for all ur help.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Are you using JSP on the server side?
Anurag Mishra
Ranch Hand

Joined: Jun 16, 2003
Posts: 121
Hi Eric,
JSP on server Side??
I am accessing EJb from my jsp's so after getting values I want to display on my page.
thanks for all ur help.
Jason Menard
Sheriff

Joined: Nov 09, 2000
Posts: 6450
Take a look at this code:

It will display..
2 : 5
This should allow you to do what you want. Like someone else here said, you can put each component into a separate table cell. The first cell could contain a[0] and the decimal point, and the second cell could contain a[1] and be set to align left.
[ April 01, 2004: Message edited by: Jason Menard ]
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

What database are you using. If you are using Oracle, you can use the to_char() function and use a format that will place leading zeros in the front.
as in
to_char(value,'fm0####.#0')
the "fm" makes sure that it is trimmed and there are no blank spaces.
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Anurag Mishra
Ranch Hand

Joined: Jun 16, 2003
Posts: 121
Hi All,
thanks a lot for ur replies,
I will try to sove my problem and post it once it works for me.
thanks
Anurag
 
GeeCON Prague 2014
 
subject: Alignment on Decimal Number