perl / ifram / javascript question
Andrej Marjan
amarjan-e+AXbWqSrlAAvxtiuMwx3w at public.gmane.org
Wed Mar 14 02:55:53 UTC 2007
Madison Kelly wrote:
> Hi all,
>
> I've got a thing I want to do with my web app that I know is
> possible but can't for the life of me figure out... I've googled this
> do death but am probably stumbling over something really simple.
>
> Anyway, I want to use perl to round a number (for now; later want to
> submit a form without reloading the whole page).
>
> So I'd like to be able to have a javascript function pass a couple
> variables to a perl script (ie:
> 'http://foo.com/cgi-bin/script?num=<real_number>&precision=<precision>').
> Then, once the perl script does it's magic, load the numbers into
> hidden form fields via an iframe for the calling script to read).
Well you could just do it in javascript, e.g. 1.563532.toPrecision(3) ==
"1.56"
Do you have a particular reason for wanting to do the rounding server-side?
I don't know if there's a cleverer way to do it in Perl, but sprintf
will do the trick, e.g. sprintf("%.2f", 1.5678).
--
The Toronto Linux Users Group. Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists
More information about the Legacy
mailing list