#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2009
    Posts
    67
    Rep Power
    5

    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.
  2. #2
  3. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,273
    Rep Power
    968
    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 &nbsp; (ASCII non-breaking space)
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2009
    Posts
    67
    Rep Power
    5
    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.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2009
    Posts
    67
    Rep Power
    5
    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?
  8. #5
  9. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,273
    Rep Power
    968
    You probably want:

    cfset varx = variables["sp#ind#"]
  10. #6
  11. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,273
    Rep Power
    968
    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.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2009
    Posts
    67
    Rep Power
    5
    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!

IMN logo majestic logo threadwatch logo seochat tools logo