<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Calculate Scripts</title>
	<atom:link href="http://forms.stefcameron.com/2006/05/15/calculate-scripts/feed/" rel="self" type="application/rss+xml" />
	<link>http://forms.stefcameron.com/2006/05/15/calculate-scripts/</link>
	<description>Building intelligent forms using Adobe LiveCycle Designer</description>
	<lastBuildDate>Thu, 19 Jan 2012 16:32:12 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Stefan Cameron</title>
		<link>http://forms.stefcameron.com/2006/05/15/calculate-scripts/#comment-4859</link>
		<dc:creator>Stefan Cameron</dc:creator>
		<pubDate>Tue, 01 Jun 2010 02:39:36 +0000</pubDate>
		<guid isPermaLink="false">http://forms.stefcameron.com/blog/?p=10#comment-4859</guid>
		<description>@Rhonda,

In order to do that, you would first have to determine what rule(s) determine that the user has finished entering a value in a field. You can check the value as the user enters it in the Change event and, if the rule(s) is(are) met, set focus to the next field by using the xfa.host.setFocus() function:

&lt;pre&gt;&lt;code&gt;xfa.host.setFocus({nextField}.somExpression);&lt;/code&gt;&lt;/pre&gt;

where {nextField} is the field to which focus should go.</description>
		<content:encoded><![CDATA[<p>@Rhonda,</p>
<p>In order to do that, you would first have to determine what rule(s) determine that the user has finished entering a value in a field. You can check the value as the user enters it in the Change event and, if the rule(s) is(are) met, set focus to the next field by using the xfa.host.setFocus() function:</p>
<pre><code>xfa.host.setFocus({nextField}.somExpression);</code></pre>
<p>where {nextField} is the field to which focus should go.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rhonda</title>
		<link>http://forms.stefcameron.com/2006/05/15/calculate-scripts/#comment-4858</link>
		<dc:creator>Rhonda</dc:creator>
		<pubDate>Thu, 20 May 2010 14:53:56 +0000</pubDate>
		<guid isPermaLink="false">http://forms.stefcameron.com/blog/?p=10#comment-4858</guid>
		<description>I&#039;m creating a form and I want each space, after filling it in, to automatically jump to the next space without having to tab to it. Can you tell me how to do that?

Thanks,
Rhonda</description>
		<content:encoded><![CDATA[<p>I&#8217;m creating a form and I want each space, after filling it in, to automatically jump to the next space without having to tab to it. Can you tell me how to do that?</p>
<p>Thanks,<br />
Rhonda</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stefan Cameron</title>
		<link>http://forms.stefcameron.com/2006/05/15/calculate-scripts/#comment-4857</link>
		<dc:creator>Stefan Cameron</dc:creator>
		<pubDate>Mon, 08 Feb 2010 20:49:13 +0000</pubDate>
		<guid isPermaLink="false">http://forms.stefcameron.com/blog/?p=10#comment-4857</guid>
		<description>Maria,

There are date and time functions available in both JavaScript (the &lt;a href=&quot;http://www.w3schools.com/jsref/jsref_obj_date.asp&quot; rel=&quot;nofollow&quot;&gt;Date&lt;/a&gt; object) and FormCalc (see the &lt;a href=&quot;http://partners.adobe.com/public/developer/xml/index_arch.html&quot; rel=&quot;nofollow&quot;&gt;XFA spec&lt;/a&gt; for the FormCalc date/time functions) that you can use to calculate the number of days between two dates.

In FormCalc, you would likely use the Date2Num function to convert the dates to numbers then determine the number of days represented by the subtraction of the first and second date.</description>
		<content:encoded><![CDATA[<p>Maria,</p>
<p>There are date and time functions available in both JavaScript (the <a href="http://www.w3schools.com/jsref/jsref_obj_date.asp" rel="nofollow">Date</a> object) and FormCalc (see the <a href="http://partners.adobe.com/public/developer/xml/index_arch.html" rel="nofollow">XFA spec</a> for the FormCalc date/time functions) that you can use to calculate the number of days between two dates.</p>
<p>In FormCalc, you would likely use the Date2Num function to convert the dates to numbers then determine the number of days represented by the subtraction of the first and second date.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Maria</title>
		<link>http://forms.stefcameron.com/2006/05/15/calculate-scripts/#comment-4856</link>
		<dc:creator>Maria</dc:creator>
		<pubDate>Sun, 31 Jan 2010 23:03:56 +0000</pubDate>
		<guid isPermaLink="false">http://forms.stefcameron.com/blog/?p=10#comment-4856</guid>
		<description>can someone please help me . i need to know how to calculate the number of days between two different dates?
Cheers,
Maria</description>
		<content:encoded><![CDATA[<p>can someone please help me . i need to know how to calculate the number of days between two different dates?<br />
Cheers,<br />
Maria</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stefan Cameron</title>
		<link>http://forms.stefcameron.com/2006/05/15/calculate-scripts/#comment-4855</link>
		<dc:creator>Stefan Cameron</dc:creator>
		<pubDate>Sun, 20 Jul 2008 22:16:58 +0000</pubDate>
		<guid isPermaLink="false">http://forms.stefcameron.com/blog/?p=10#comment-4855</guid>
		<description>Tom,

You can use the Script Editor palette (&quot;Window menu &gt; Script Editor&quot;) to script the forms Initialize event which is fired when the PDF is loading.

You mentioned that &quot;Reader seems to be caching old SQL query results.&quot; I assume, then, that you&#039;ve extended your PDF, using &lt;a href=&quot;http://www.adobe.com/products/livecycle/readerextensions/&quot; rel=&quot;nofollow&quot;&gt;LiveCycle Reader Extensions&lt;/a&gt;, to allow for &lt;a href=&quot;http://forms.stefcameron.com/2006/08/12/importing-data-in-acrobat/&quot; rel=&quot;nofollow&quot;&gt;data import in Reader&lt;/a&gt; or that you&#039;re using &lt;a href=&quot;http://www.adobe.com/products/livecycle/forms/&quot; rel=&quot;nofollow&quot;&gt;LiveCycle Forms&lt;/a&gt; to serve the form to the browser?

As far as pre-populating a form with a query and then permitting the user to make edits and save it to their desktop, you would just ensure that your initialization script, that runs when the PDF is loaded, only runs once (e.g. if a particular field, that gets filled as a result of the query, is already filled, don&#039;t let the query execute again). You can manually execute an ODBC data connection by using the open() method:

&lt;pre&gt;&lt;code&gt;if (can_run_query)
{
    ...
    myDataConnection.open(); // execute query
}&lt;/code&gt;&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Tom,</p>
<p>You can use the Script Editor palette (&#8220;Window menu > Script Editor&#8221;) to script the forms Initialize event which is fired when the PDF is loading.</p>
<p>You mentioned that &#8220;Reader seems to be caching old SQL query results.&#8221; I assume, then, that you&#8217;ve extended your PDF, using <a href="http://www.adobe.com/products/livecycle/readerextensions/" rel="nofollow">LiveCycle Reader Extensions</a>, to allow for <a href="http://forms.stefcameron.com/2006/08/12/importing-data-in-acrobat/" rel="nofollow">data import in Reader</a> or that you&#8217;re using <a href="http://www.adobe.com/products/livecycle/forms/" rel="nofollow">LiveCycle Forms</a> to serve the form to the browser?</p>
<p>As far as pre-populating a form with a query and then permitting the user to make edits and save it to their desktop, you would just ensure that your initialization script, that runs when the PDF is loaded, only runs once (e.g. if a particular field, that gets filled as a result of the query, is already filled, don&#8217;t let the query execute again). You can manually execute an ODBC data connection by using the open() method:</p>
<pre><code>if (can_run_query)
{
    ...
    myDataConnection.open(); // execute query
}</code></pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom</title>
		<link>http://forms.stefcameron.com/2006/05/15/calculate-scripts/#comment-4854</link>
		<dc:creator>Tom</dc:creator>
		<pubDate>Mon, 14 Jul 2008 22:14:32 +0000</pubDate>
		<guid isPermaLink="false">http://forms.stefcameron.com/blog/?p=10#comment-4854</guid>
		<description>Hi, I have two semi-related questions.

I am wondering where I would insert a script tag to handle the main loading event of the PDF form. I am trying to run an SQL query to prepopulate a PDF form, but Adobe Reader seems to be caching older SQL query results. I want to be able to clear the cache, or clear the form then run the SQL query.

Also, is there some way to pre-populate a form once with a query, then have usage-rights enabled so that a user can make small edits to the form if saved on there desktop? The PDF form is being served up on a web server. My webpage allows a user to search ID&#039;s, then prepopulate the form based on the target ID.</description>
		<content:encoded><![CDATA[<p>Hi, I have two semi-related questions.</p>
<p>I am wondering where I would insert a script tag to handle the main loading event of the PDF form. I am trying to run an SQL query to prepopulate a PDF form, but Adobe Reader seems to be caching older SQL query results. I want to be able to clear the cache, or clear the form then run the SQL query.</p>
<p>Also, is there some way to pre-populate a form once with a query, then have usage-rights enabled so that a user can make small edits to the form if saved on there desktop? The PDF form is being served up on a web server. My webpage allows a user to search ID&#8217;s, then prepopulate the form based on the target ID.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stefan Cameron</title>
		<link>http://forms.stefcameron.com/2006/05/15/calculate-scripts/#comment-4853</link>
		<dc:creator>Stefan Cameron</dc:creator>
		<pubDate>Wed, 25 Jun 2008 23:05:11 +0000</pubDate>
		<guid isPermaLink="false">http://forms.stefcameron.com/blog/?p=10#comment-4853</guid>
		<description>Matt,

I&#039;m glad you got it to work.

To prevent unwanted characters from being input into the field, you have to script the Change event and look at the xfa.event.change property which contains the character that the user has typed. Since this happens before the character is actually inserted into the field, you can essentially cancel the character input by setting that property to an empty string.

Here&#039;s a quick little sample, written in JavaScript, that excludes all non-numeric characters from the input:

&lt;pre&gt;&lt;code&gt;var newChar = xfa.event.change;
var re = new RegExp(&quot;\\d&quot;); // verify the character is a single digit

if (newChar.match(re) == null)
	xfa.event.change = &quot;&quot;; // cancel the character input&lt;/code&gt;&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Matt,</p>
<p>I&#8217;m glad you got it to work.</p>
<p>To prevent unwanted characters from being input into the field, you have to script the Change event and look at the xfa.event.change property which contains the character that the user has typed. Since this happens before the character is actually inserted into the field, you can essentially cancel the character input by setting that property to an empty string.</p>
<p>Here&#8217;s a quick little sample, written in JavaScript, that excludes all non-numeric characters from the input:</p>
<pre><code>var newChar = xfa.event.change;
var re = new RegExp("\\d"); // verify the character is a single digit

if (newChar.match(re) == null)
	xfa.event.change = ""; // cancel the character input</code></pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt</title>
		<link>http://forms.stefcameron.com/2006/05/15/calculate-scripts/#comment-4852</link>
		<dc:creator>Matt</dc:creator>
		<pubDate>Wed, 25 Jun 2008 11:32:36 +0000</pubDate>
		<guid isPermaLink="false">http://forms.stefcameron.com/blog/?p=10#comment-4852</guid>
		<description>Please disregard my previous post as I have figured out what to do.

Is there a way to check the field for numeric only entries, I need to work on catch and error messages. I do not want a user to type a alpha character as a time entry.</description>
		<content:encoded><![CDATA[<p>Please disregard my previous post as I have figured out what to do.</p>
<p>Is there a way to check the field for numeric only entries, I need to work on catch and error messages. I do not want a user to type a alpha character as a time entry.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt</title>
		<link>http://forms.stefcameron.com/2006/05/15/calculate-scripts/#comment-4851</link>
		<dc:creator>Matt</dc:creator>
		<pubDate>Tue, 24 Jun 2008 18:03:37 +0000</pubDate>
		<guid isPermaLink="false">http://forms.stefcameron.com/blog/?p=10#comment-4851</guid>
		<description>I am very new to Adobe as well (8.0) I am using LiveCycle Designer to create a timesheet as well and this is over my head. I have developed a form, included in that form is a table 9 Columns: Day, Date, Time In, Lunch Out, Lunch In, Time Out, Paid Leave, Type of Leave, Total Hours Worked. Rows of course would include days of the week and the user would enter data for that particular date. I want to capture the total hours to include any paid leave taken. I understand that calculations have to take place but I can only seem to get funky results: Fields are data and time. Data pattern: HH:MM, data format: time

My sample result for just one time calculation: Time In Displays 7:30AM, Lunch Out Displays 11:00AM and my total hours worked is 370 which is correct if you just subtract 1100-730. If I could just see a snipet of one time calculation and learn from it I should be able to do this. Any assistance on this would be greatly appreciated.</description>
		<content:encoded><![CDATA[<p>I am very new to Adobe as well (8.0) I am using LiveCycle Designer to create a timesheet as well and this is over my head. I have developed a form, included in that form is a table 9 Columns: Day, Date, Time In, Lunch Out, Lunch In, Time Out, Paid Leave, Type of Leave, Total Hours Worked. Rows of course would include days of the week and the user would enter data for that particular date. I want to capture the total hours to include any paid leave taken. I understand that calculations have to take place but I can only seem to get funky results: Fields are data and time. Data pattern: HH:MM, data format: time</p>
<p>My sample result for just one time calculation: Time In Displays 7:30AM, Lunch Out Displays 11:00AM and my total hours worked is 370 which is correct if you just subtract 1100-730. If I could just see a snipet of one time calculation and learn from it I should be able to do this. Any assistance on this would be greatly appreciated.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stefan Cameron</title>
		<link>http://forms.stefcameron.com/2006/05/15/calculate-scripts/#comment-4850</link>
		<dc:creator>Stefan Cameron</dc:creator>
		<pubDate>Sun, 08 Jun 2008 02:49:46 +0000</pubDate>
		<guid isPermaLink="false">http://forms.stefcameron.com/blog/?p=10#comment-4850</guid>
		<description>Chelsea,

I&#039;m sure we can get this working for you however I would need to know how you&#039;ve created your timesheet before I can recommend how you should write your script. Are you using a table where each column is a field that represents start time, end time, break start, etc.? If you aren&#039;t using a table, are you using subforms and if so, how have you structured them (how are they nested)?</description>
		<content:encoded><![CDATA[<p>Chelsea,</p>
<p>I&#8217;m sure we can get this working for you however I would need to know how you&#8217;ve created your timesheet before I can recommend how you should write your script. Are you using a table where each column is a field that represents start time, end time, break start, etc.? If you aren&#8217;t using a table, are you using subforms and if so, how have you structured them (how are they nested)?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

