JRS: In article <jaG3e.11549$k66.275@trnddc03>, dated Sat, 2 Apr 2005
23:47:27, seen in news:comp.lang.javascript, JK <> posted :
>This is an easy one, but I'm a JS newbie. I want to write a function that
>determines input value. If 0 - 100 than will use input as % (i.e., 3 would
>become .03 and used for calculations); otherwise, as dollar value (i.e.,
>1,000 would become $1,000 and used for calculations). In other words, I want
>input.value 3 to either be input.value 1 * input.value 2, or simply =
>input.value 1. Please be specific about placement of function (header or
>body, placement inside another function, etc), I am just a newbie.
It is unlikely to be wise to make the behaviour and meaning of an input
depend in such a discontinuous manner on its numerical magnitude.
Use a percentage box for percentages, making it clear what it is a
percentage of, and use a dollar box for dollars - remembering that on
the World Wide Web the dollar (if American) is steadily becoming less
useful as a unit of currency, so alternatives should be provided.
Or use a single box, requiring the presence of either a recognisable
leading currency symbol or a trailing percentage sign.
Or two numeric input, with a checkbox to enable the percenter.
Or a single box with a radio-button pair to select the nature of the
input.
If you had broken up your description better, it would have been more
readable -
If you are envisaging "full" use as box 3 = [(box 2 %) of]? (box 1 $),
then preload box 2 with 100.0, then a button, then box 3 : something
like
---------------- ----------- ---- -----------
Enter : $ | | * |100.0 | % | => | $ | |
---------------- ----------- ---- -----------
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
|