[thelist] JavaScript -- calculating & printing

lon.kraemer lwkraemer at earthlink.net
Mon Apr 9 16:30:59 CDT 2001

Actually, there is a reasonable way to handle this using your processData()
function. Rather than calling it as a form submission function (you used
onclick at the button, I prefer onsubmit at the form), simply add:

onfocus="this.value=0;select()" onblur="processData()" [no function

to each of the inputs. This will recalculate the entire form each time
something is changed.

Whadaya think?
Lon Kraemer
Web Design/ASP Development

----- Original Message -----
From: "Luther, Ron" <Ron.Luther at COMPAQ.com>
To: <thelist at lists.evolt.org>
Sent: Monday, April 09, 2001 2:01 PM
Subject: RE: [thelist] JavaScript -- calculating & printing

> 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
> 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
> "prettier"!
> 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
> site! [even a single page] ... Basically it's a design issue that would
> 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,
> the number of places entered, and applying a "smart" rounding function
> 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
> RonL.
> -----Original Message-----
> Lauri,
> Even Ron's sample demonstrates a basic flaw. What if the user fills in
> metric and imperial for a given dimension. How do you know which one was
> intended?
> I'm inclined to suggest using a radio select for type (meters or feet),
> inputs for the appropriate measurements... using Ron's calculator
> Of course they couldn't mix units once the radio was selected!

More information about the thelist mailing list