Print Page | Close Window

App.Alert function help needed

Printed From: Foxit's Planet PDF Forum
Category: Lets Talk PDF
Forum Name: JavaScript
Forum Description: Discussions relating to the use of JavaScript within PDF.
URL: http://forums.planetpdf.com/forum_posts.asp?TID=1080
Printed Date: 19 Jul 2019 at 9:03am
Software Version: Web Wiz Forums 11.10 - http://www.webwizforums.com


Topic: App.Alert function help needed
Posted By: Chandra
Subject: App.Alert function help needed
Date Posted: 24 Jan 2014 at 8:42pm
I have a timesheet form that I have prepared. The timekeeper enters hours worked and the form calculates the hours absent. If the hours worked is less than 7.5 hours, the form should prompt the timekeeper to select an absent code from a drop down box. If the timekeeper later changes the hours worked to more than 7.5, the absent code should be reset to the default value, which is " ".

The code I have entered on blur is:

a = this.getField("HrsWrkdMonday").value;
b = this.getField("AbCodeMonday").value;

if (a<7.5 && b===" ")
    {
    b.setFocus()
    app.alert("Please enter Absent Code for Monday.")
    }
else if (a>7.5 && b!=" ")
    {
    b=" "
    }

Any assistance would be greatly appreciated.



Replies:
Posted By: try67
Date Posted: 25 Jan 2014 at 10:14am
It will help if you say what the actual problem is...

I do see several issues with your code, though:
1. To access the value of the field you're exiting from you should use event.target.value.
Better yet, use a Validation code and then access "event.value".
2. You're trying to call setFocus() on a string (the variable "b"), instead of on a field.
3. You need to assign a value to a field directly.
This line will not change the value of the field:
b=" "
It will only change the value of the b variable.


-------------
- Acrobat Expert - Contact me personally at try6767@gmail.com
Check out my custom-made scripts website: http://try67.blogspot.com


Posted By: Chandra
Date Posted: 27 Jan 2014 at 5:58pm
Thanks for the reply and my apologies for not being more specific. I am new to javascript and have been able to piece together what I have found in the forum to create a timesheet. The form requires the timekeeper to enter the total hours worked for a specific day (i.e., Monday, Tuesday, etc.). The field name for this field for Monday is "HrsWrkdMonday". If the hours worked are less than a full work day (7.5 hours) the form calculates the hours absent (HrsAbsentMonday); if the hours worked are more than a full work day the form calculates the hours of overtime (HrsOTMonday). The form then calculates the totals for each of these for the week.

I have created a dropdown list of applicable absent codes. If the hours worked are less than 7.5 (and therefore the hours absent is greater than 0) I would like to have an app.alert command to tell the timekeeper they must enter an absent code. The form should then highlight the absent code field for the user to select one from the drop down box.

Additionally, if the timekeeper then goes back and changes the HrsWrkdMonday to greater than 7.5 the AbCodeMonday should be set back to the default value of " ". I would suspect the javascript would go in the AbCodeMonday field; Action->On Blur->Run a JavaScript.

Thank you for the time (and patience).



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.10 - http://www.webwizforums.com
Copyright ©2001-2017 Web Wiz Ltd. - https://www.webwiz.net