From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/54643 Path: news.gmane.org!not-for-mail From: jeroen muskee Newsgroups: gmane.comp.tex.context Subject: Re: Fields and JS Calculations Date: Mon, 23 Nov 2009 01:07:08 +0100 Message-ID: References: Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0141544733==" X-Trace: ger.gmane.org 1258935081 27352 80.91.229.12 (23 Nov 2009 00:11:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 23 Nov 2009 00:11:21 +0000 (UTC) To: Original-X-From: ntg-context-bounces@ntg.nl Mon Nov 23 01:11:14 2009 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([195.12.62.10]) by lo.gmane.org with esmtp (Exim 4.50) id 1NCMWP-0000ok-E6 for gctc-ntg-context-518@m.gmane.org; Mon, 23 Nov 2009 01:11:13 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 35790C9B21; Mon, 23 Nov 2009 01:06:43 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id lwDxDUv-JBwW; Mon, 23 Nov 2009 01:06:28 +0100 (CET) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id AC2ACC9B0D; Mon, 23 Nov 2009 01:06:22 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 43F3AC9B0D for ; Mon, 23 Nov 2009 01:06:01 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id tfAJSf0YRa3V for ; Mon, 23 Nov 2009 01:05:46 +0100 (CET) Original-Received: from col0-omc2-s16.col0.hotmail.com (col0-omc2-s16.col0.hotmail.com [65.55.34.90]) by balder.ntg.nl (Postfix) with ESMTP id 41EDCC9AF1 for ; Mon, 23 Nov 2009 01:05:42 +0100 (CET) Original-Received: from COL115-W14 ([65.55.34.71]) by col0-omc2-s16.col0.hotmail.com with Microsoft SMTPSVC(6.0.3790.3959); Sun, 22 Nov 2009 16:07:08 -0800 X-Originating-IP: [213.219.150.27] Importance: Normal In-Reply-To: X-OriginalArrivalTime: 23 Nov 2009 00:07:08.0497 (UTC) FILETIME=[E5B93410:01CA6BD0] X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.12 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl Xref: news.gmane.org gmane.comp.tex.context:54643 Archived-At: --===============0141544733== Content-Type: multipart/alternative; boundary="_51d26792-f9f1-402b-87ea-b37ecf7b3048_" --_51d26792-f9f1-402b-87ea-b37ecf7b3048_ Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable OK=2C I started off with a simpler example=2C just an addition of 2 numbers= . I know this should be pretty close to the correct setup by looking at oth= er Javascript examples=2C but it just does not work jet. Any suggestions =20 Thanks Jeroen =20 =20 \startJSpreamble {Calculate} used now function Calculate () { v =3D getField("textC") =3B v.value =3D 0 =3B v.value +=3D AFMakeNumber(getField("textA").value) =3B v.value +=3D AFMakeNumber(getField("textB").value) } \stopJSpreamble =20 \starttext=20 =20 \setupfield=20 [lineABC]=20 [label=2Cframe=2Chorizontal]=20 [frame=3Doff]=20 [height=3D18pt=2Cwidth=3D15em=2Calign=3Dmiddle=2Cframe=3Doff]=20 [height=3D18pt=2Cwidth=3D20em=2Calign=3Dright=2Cstyle=3D\tfx=2C=2Cframe=3Do= n]=20 =20 \definefield[textA] [line] [lineABC] [] []=20 \definefield[textB] [line] [lineABC] [] []=20 \definefield[textC] [line] [lineABC] [] []=20 =20 \startJScode{Calculate}=20 AFSimple_Calculate("SUM"=2C new Array ("textA"=2C "textB"))=3B=20 \stopJScode=20 =20 Calculate the addition: A + B =3D C \\ \field[textA][Please enter A]=20 \\ \field[textB][Please enter B]=20 \\=20 \goto{Calculate the Result}[JS(Calculate)] \\ \field[textC][The Calculation Result C =3D ]=20 =20 \stoptext =20 From: jeroen.muskee@hotmail.com To: ntg-context@ntg.nl Date: Sat=2C 21 Nov 2009 14:19:03 +0100 Subject: [NTG-context] Fields and JS Calculations I want to calculate the pressure of a hydrostatic fluid column with p(psi)= =3D0.052*density(lb/gal)*depth(ft) I have created a form with fields to enter the input=2C but I need somehow = to pass the information entered to the JS calculation to display the result= . How can you pass an entered field value to JS caluclation and show the resu= lt into another field. =20 Thanks Jeroen =20 =20 =20 \setupcolors[state=3Dstart]=20 \setupinteraction[state=3Dstart]=20 =20 \starttext=20 =20 \definefield[textdensity] [line] [linedensity] [] []=20 \definefield[textdepth] [line] [linedepth] [] []=20 \definefield[textpressure] [line] [linepressure] [] []=20 =20 \setupfield=20 [linedensity]=20 [label=2Cframe=2Chorizontal]=20 [frame=3Doff]=20 [height=3D18pt=2Cwidth=3D15em=2Calign=3Dmiddle=2Cframe=3Doff]=20 [height=3D18pt=2Cwidth=3D20em=2Calign=3Dright=2Cstyle=3D\tfx=2C=2Cframe=3Do= n]=20 =20 \setupfield=20 [linedepth]=20 [label=2Cframe=2Chorizontal]=20 [frame=3Doff]=20 [height=3D18pt=2Cwidth=3D15em=2Calign=3Dmiddle=2Cframe=3Doff]=20 [height=3D18pt=2Cwidth=3D20em=2Calign=3Dright=2Cstyle=3D\tfx=2C=2Cframe=3Do= n]=20 =20 \setupfield=20 [linepressure]=20 [label=2Cframe=2Chorizontal]=20 [frame=3Doff]=20 [height=3D18pt=2Cwidth=3D15em=2Calign=3Dmiddle=2Cframe=3Doff]=20 [height=3D18pt=2Cwidth=3D20em=2Calign=3Dright=2Cstyle=3D\tfx=2C=2Cframe=3Do= n]=20 =20 \startJScode{presscalc} pressure=3D0.052*density*depth=3B \stopJScode =20 Calculate the hydrostatic pressure in psi with p =3D 0.05194 x density x de= pth \blank \field[textdensity][Please enter Density (lb/gal):]=20 \blank \field[textdepth][Please enter Depth (ft):]=20 \blank=20 \goto{Calculate Pressure}[JS(presscalc)] \blank \field[textpressure][Hydrostatic Pressure (psi):]=20 =20 \stoptext Windows Live: Make it easier for your friends to see what you=92re up to on= Facebook. =20 _________________________________________________________________ Windows Live: Friends get your Flickr=2C Yelp=2C and Digg updates when they= e-mail you. http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/so= cial-network-basics.aspx?ocid=3DPID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_3:092= 010= --_51d26792-f9f1-402b-87ea-b37ecf7b3048_ Content-Type: text/html; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable OK=2C I started off with a simpler example=2C just an addition of 2 numbers= . I know this should be pretty close to the correct setup by looking at oth= er Javascript examples=2C but it just does not work jet. Any suggestions  =3B
Thanks
Jeroen
 =3B
 =3B

\startJ= Spreamble {Calculate} used now

functio= n Calculate ()

{ v =3D= getField("textC") =3B v.value =3D 0 =3B

v.value= +=3D AFMakeNumber(getField("textA").value) =3B

v.value= +=3D AFMakeNumber(getField("textB").value) }

\stopJS= preamble

 = =3B

\startt= ext

 = =3B

\setupf= ield

[lineAB= C]

[label= =2Cframe=2Chorizontal]

[frame= =3Doff]

[height= =3D18pt=2Cwidth=3D15em=2Calign=3Dmiddle=2Cframe=3Doff]

[height= =3D18pt=2Cwidth=3D20em=2Calign=3Dright=2Cstyle=3D\tfx=2C=2Cframe=3Don]

 = =3B

\define= field[textA] [line] [lineABC] [] []

\define= field[textB] [line] [lineABC] [] []

\define= field[textC] [line] [lineABC] [] []

 = =3B

\startJ= Scode{Calculate}

AFSimpl= e_Calculate("SUM"=2C new Array ("textA"=2C "textB"))=3B

\stopJS= code

 = =3B

Calcula= te the addition: A + B =3D C

\\

\field[= textA][Please enter A]

\\

\field[= textB][Please enter B]

\\

\goto{C= alculate the Result}[JS(Calculate)]

\\

\field[= textC][The Calculation Result C =3D ]

 = =3B

\stopte= xt
 =3B


From: jeroen.muskee@hotmail.com
To: ntg-context@ntg.nl
Date: Sat=2C 2= 1 Nov 2009 14:19:03 +0100
Subject: [NTG-context] Fields and JS Calculati= ons

I want to calculate the pressure of a hydrostatic fluid column with p(psi)= =3D0.052*density(lb/gal)*depth(ft)
I have created a form with fields to = enter the input=2C but I need somehow to pass the information entered to th= e JS calculation to display the result.
How can you pass an entered fiel= d value to JS caluclation and show the result into another field.
 = =3B
Thanks
Jeroen
 =3B
 =3B
 =3B
\setupcolors= [state=3Dstart]

\setupinteraction[state=3Dstart]

 =3B

\starttext

 =3B

\definefield[textdensity] [line] [linedensity= ] [] []

\definefield[textdepth] [line] [linedepth] []= []

\definefield[textpressure] [line] [linepressu= re] [] []

 =3B

\setupfield

[linedensity]

[label=2Cframe=2Chorizontal]

[frame=3Doff]

[height=3D18pt=2Cwidth=3D15em=2Calign=3Dmiddl= e=2Cframe=3Doff]

[height=3D18pt=2Cwidth=3D20em=2Calign=3Dright= =2Cstyle=3D\tfx=2C=2Cframe=3Don]

 =3B

\setupfield

[linedepth]

[label=2Cframe=2Chorizontal]

[frame=3Doff]

[height=3D18pt=2Cwidth=3D15em=2Calign=3Dmiddl= e=2Cframe=3Doff]

[height=3D18pt=2Cwidth=3D20em=2Calign=3Dright= =2Cstyle=3D\tfx=2C=2Cframe=3Don]

 =3B

\setupfield

[linepressure]

[label=2Cframe=2Chorizontal]

[frame=3Doff]

[height=3D18pt=2Cwidth=3D15em=2Calign=3Dmiddl= e=2Cframe=3Doff]

[height=3D18pt=2Cwidth=3D20em=2Calign=3Dright= =2Cstyle=3D\tfx=2C=2Cframe=3Don]

 =3B

\startJScode{presscalc}

pressure=3D0.052*density*depth=3B

\stopJScode

 =3B

Calculate the hydrostatic pressure in psi wit= h p =3D 0.05194 x density x depth

\blank

\field[textdensity][Please enter Density (lb/= gal):]

\blank

\field[textdepth][Please enter Depth (ft):] <= /P>

\blank

\goto{Calculate Pressure}[JS(presscalc)]

\blank

\field[textpressure][Hydrostatic Pressure (ps= i):]

 =3B

\stoptext



Windows Live: Make it easier for your friends to see what y= ou=92re up to on Facebook.

Windows Live: Friends get your Flickr=2C Yelp=2C and Digg updat= es when they e-mail you. = --_51d26792-f9f1-402b-87ea-b37ecf7b3048_-- --===============0141544733== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ --===============0141544733==--