The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages - More
> ColdFusion Development
|
Right-justifying 1 field in a line of 5
Discuss Right-justifying 1 field in a line of 5 in the ColdFusion Development forum on Dev Shed. Right-justifying 1 field in a line of 5 ColdFusion Development forum discussing CFML coding practices, tips on CFML, and other CFML related topics. Find out why ColdFusion is the tool of choice for many e-commerce developers.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

January 1st, 2013, 03:36 AM
|
|
Contributing User
|
|
Join Date: Oct 2009
Posts: 59
Time spent in forums: 11 h 27 m 24 sec
Reputation Power: 4
|
|
|
Right-justifying 1 field in a line of 5
if have the following:
Code:
<div>Delivery#theNum#:#theQty##theUnit##theDate#</div>
I want #theQty#, a number, to be right-justified with a fixed-width. I've tried many variations without success.
|

January 2nd, 2013, 11:10 AM
|
|
Moderator
|
|
Join Date: Jun 2002
Location: Raleigh, NC
|
|
|
I don't think it's possible that way. You can wrap it in a span and float right but that won't work with it being in the middle of other elements. You may need to try writing a small function that pads it with (ASCII non-breaking space)
|

January 2nd, 2013, 08:00 PM
|
|
Contributing User
|
|
Join Date: Oct 2009
Posts: 59
Time spent in forums: 11 h 27 m 24 sec
Reputation Power: 4
|
|
|
kiteless, thank you. This is really weird because I went looking for my post, under my log-in name, to update some experiment results and couldn't find it. So, assuming I had been dreaming, I started a new thread in the CSS forum (Intraline: 3 items left-aligned, 1 right-aligned). Your suggestion is interesting - do the right-justify via a script or function. Thanks again, I'll work on that!
Last edited by new2cfrb : January 2nd, 2013 at 08:03 PM.
|

January 2nd, 2013, 10:46 PM
|
|
Contributing User
|
|
Join Date: Oct 2009
Posts: 59
Time spent in forums: 11 h 27 m 24 sec
Reputation Power: 4
|
|
|
ok, got quite a lot further but I'm stumped on a bit of syntax.
I have several variables sp1, sp2, sp3. I want to assign the contents of one of them to varx. The choice of source variable is decided by another called ind. Now, I can use a series of CFIF's or a dynamic address something like:
cfset varx = #["sp"&#ind#]#
Anyone know the correct syntax?
|

January 2nd, 2013, 11:59 PM
|
|
Moderator
|
|
Join Date: Jun 2002
Location: Raleigh, NC
|
|
|
You probably want:
cfset varx = variables["sp#ind#"]
|

January 3rd, 2013, 12:06 AM
|
|
Moderator
|
|
Join Date: Jun 2002
Location: Raleigh, NC
|
|
Also, this is just some random advice, but those variable names are terrible. "varx", "sp", "ind", "sp1", etc. tell you nothing about what it actually IS. Not sure if this is just because you're testing things out, but don't skimp on descriptive variable names.
cfset paddedQuantity = variables[ "quantity#orderCounter#" ]
Is infinitely more useful. 
|

January 3rd, 2013, 03:32 AM
|
|
Contributing User
|
|
Join Date: Oct 2009
Posts: 59
Time spent in forums: 11 h 27 m 24 sec
Reputation Power: 4
|
|
|
kiteless - thanks for the syntax, worked a treat and much more elegant. The alignment was enhanced by the adoption of the "Courier New" non-proportional font.
Excellent advice about datanames - I do use more meaningful names in my code (an old (in many ways) Cobol programmer), I was simplifying for the exercise.
Problem solved!
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|