[thelist] JavaScript -- calculating & printing

Luther, Ron Ron.Luther at COMPAQ.com
Mon Apr 9 16:01:39 CDT 2001

Hi Lon,

Good catch! ... (Yeah - I noticed that ... it didn't bother me enough to
look too deeply at - the behavior is consistent ... if you fill in both ...
metric is assumed to be your 'real' input.... and things trundle along.) 

Does that make this a "training" issue rather than a "coding" issue?  <he
says (with a very small dose of seriousness for this 'project'- but perhaps
not for some others) and ducks quickly>

I like the radio button idea though .... and I've seen a JS calculator
somewhere that I think used a drop-down to let you select any one of 40 or
so different conversions - one input, one output - and a whole lot

I'm sure the "quickie" I threw up has more flaws than that ... but 'user
interface design and ease of operability' are worthwhile issues for any size
site! [even a single page] ... Basically it's a design issue that would have
to be negotiated with the client - finding the 'easiest', 'clearest' and
'most intuitive' design.... which could very well not be the one here!

Lauri's note on the "precision problem" bugged me more.  [It gets even
'cooler' - since different browser versions return different values in the
last digit to the right!  {lifted from a quick look at Danny Goodman's
JavaScript Bible}]  Welcome to floating point headaches!

While I didn't have time to fix it yet ... phone calls and work getting in
the way  ;-) ... I suspect that working with the input as a string, parsing
the number of places entered, and applying a "smart" rounding function could
do a better job. 

Lauri's last question - "What do you really do?" might be a cool thread on
thechat ... since not all of us develop public sites ... or even work in IT!


-----Original Message-----

Even Ron's sample demonstrates a basic flaw. What if the user fills in BOTH
metric and imperial for a given dimension. How do you know which one was

I'm inclined to suggest using a radio select for type (meters or feet), then
inputs for the appropriate measurements... using Ron's calculator functions.
Of course they couldn't mix units once the radio was selected!

More information about the thelist mailing list