Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Alignment on Decimal Number

 
Anurag Mishra
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 263
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Anurag Mishra
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using JSP on the server side?
 
Anurag Mishra
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6450
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Anurag Mishra
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic