ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* calculate in forms
@ 1999-12-20 14:48 Haseloff, Lutz
  1999-12-20 15:54 ` Hans Hagen
  1999-12-22 21:47 ` Hans Hagen
  0 siblings, 2 replies; 4+ messages in thread
From: Haseloff, Lutz @ 1999-12-20 14:48 UTC (permalink / raw)


Hi all, Hi Hans,

I want to prepare a form with calculating fields.
My file looks like this:
.....
\startJScode{Format}
AFNumber_Format(2, 3, 0, 0, "", true);
\stopJScode
\startJScode{Keystroke}
AFNumber_Keystroke(2, 3, 0, 0, "", true);
\stopJScode
\startJScode{Calculate}
AFSimple_Calculate("SUM", new Array ("Summand1", "Summand2"));
\stopJScode
.......%%% I use the Scripts from AForm.js because my JS programming is poor
\setupfield
  [ErgSetup]

[frame=on,width=8cm,height=4ex,format=JS(Format),afterkey=JS(Keystroke),calc
ulate=JS(Calculate)]
........
\hbox to 11cm{Summand 2:\hfill  \field[Summand2]}

\hbox to 11cm{Ergebnis :\hfill  \field[Ergebnis]}
...........

All scripts are at the right places in the pdf-file (tested with Acrobat)
and the format and afterkey
scripts work very fine.
Only the calculation does not work.

Is it possible that the missing  "/CO [...]" near /Fields is the Reason?
In the PDF Specification the "Calculate Order" is required.

Greetings

Lutz


^ permalink raw reply	[flat|nested] 4+ messages in thread
* Re: calculate in forms
@ 1999-12-28 10:19 Haseloff, Lutz
  0 siblings, 0 replies; 4+ messages in thread
From: Haseloff, Lutz @ 1999-12-28 10:19 UTC (permalink / raw)
  Cc: ntg-context

Hi Hans, Hi all,

> \startJSpreamble {Calculate} used now
>   function Calculate ()
>     { v = getField("Ergebnis") ; v.value = 0 ;
>       v.value += getField("Summand1").value ;
>       v.value += getField("Summand2").value }
> \stopJSpreamble

This treats the values like strings if they contain other seperators as a
dot
I changed your solution to:

\startJSpreamble {Calculate} used now
  function Calculate ()
    { v = getField("Ergebnis") ; v.value = 0 ;
      v.value += AFMakeNumber(getField("Summand1").value) ;
      v.value += AFMakeNumber(getField("Summand2").value)  }
\stopJSpreamble

and this works very nice for me.

Thank you very much

Happy New Year

Lutz


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1999-12-28 10:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-12-20 14:48 calculate in forms Haseloff, Lutz
1999-12-20 15:54 ` Hans Hagen
1999-12-22 21:47 ` Hans Hagen
1999-12-28 10:19 Haseloff, Lutz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).