How to calculate fields in a form?

Hello,
I am new to apex and i have a question about create a simple calculation in a form.
I created a form and i have 3 fields which i want to use for calculating.
Field 1/ field 2 = field 3
when the user enters data into the first and second field it will automatically calculate the third field.
How can i do this?
i am using
Application Express 4.2.1.00.08

The short answer is that it depends. I'm assuming you want the calculation to appear as soon as the second value is put in, and if this is the case then javascript is the answer. You can create a generic javascript function that does division and takes to input parameters and returns the result. Inside the function you would check to make sure the denominator isn't zero (an illegal operation), do the math and assign the calculated value to the return value of the function.
The function code would look something like this:
function div_values(numerator, denominator) {
// pass page item names into the function
// $v will get the value from the item name
if ($v(denominator) != 0) {
result = $v(numerator)/$v(denominator);
return result;
}Then you can call the function via a dynamic action by selecting a "Javascript Expression" for a Set Value operation (Advanced dynamic actions) and put this into the Javascript expression area:
div_values(P1_NUMERATOR,P1_DENOMINATOR)
The reason I recommend creating this little function as opposed to just doing the math in the javascript expression area is that the function becomes reusable and the page items aren't hard coded into the function. Then you can use the function wherever you want to on the page or, if you put it in a place where every page can get to it, you can use it anywhere in the app.
Earl

Similar Messages

  • How to hide fields in UIX form

    Hi
    I need to update the table with last_updated_by and last_updated_date every time if any change to the record. But I do not want to show these 2 fields on the screen.
    Could you help me how to hide fields in UIX form/any procedure to insert the data to database with out placing them in the screen .
    Thanks in advance.
    NRK

    Now that you mention it ... the rendered flag will stop the field from being rendered. So it's not even in the page. Stupid me.
    Have a look at formValue. These are rendered, but invisible fields in a form. That should do it (hopefully).
    In prepareForDML() you could simply call the setter of your date attribute that stores the date of the last update. There you pass the current date, or you could fetch the sysdate from the database and pass that. If you go that way, then the EntityImpl could make these adjustments automatically when inserting or updating and you wouldn't even need these fields/bindings in your UIX page.
    Just check what the operation is, and if it's an update or insert then call the setters of the attributes you want to update. Then call super.prepareForDML(). Something like that.
    It all would happen in the middle-tier, client not involved.
    So formValue should work, and the prepareForDML() stuff should also work. Don't know which way you want to go.
    Sascha

  • How to hide field in adobe Forms

    i  am currently trying to print purchase order where i have 5 line item  and the 5th  item is delivered so for that i want to display a text but the problem is iit  displaying in line item 10 can anyone please how to print it in 5th line

    Hii,
    Try to add one more field for  text field for each line item and make sure use a flag .
    if the flag is true then make it visible use the below JavaScript code to hide a particular field.
    his script will hide the field in runtime if it is initial.
    hidden or presence make sure use the conditions as per the require to hide the text or to make it visible
    Enter the below JavaScript in the editor & Select the language as JavaScript. 
    if(this.rawValue == null)
      this.presence = "hidden";
    Edited by: Rajan.Dexter9 on Jan 20, 2012 12:17 PM

  • How to activate fields "Start Reason" and "End Reason" in "Contact" form?

    Hello all,
    We recently migrated HRMS from version 11.5.7 to *12.1.3*. In the previous version users filled the fields Start Reason and End Reason in the Contact form (PERWSDPC), section Contact Relationship.
    In our 12.1.3 version these fields are read-only and I can not figure out how to activate them.
    PS: I have populated the list of values that should be used in the above fields, using the form Life Event Reasons (Total Compensation: General Definitions: Additional Setup: Life Event Reasons) and setting the Type field value with Personal, but I don't know how activate the fields in Contact form.
    Any suggestions?
    Thanks
    Paolo Bertinetto
    Edited by: user3312880 on 7-gen-2013 2.11

    But in addition to entering values in *Life Event Reasons" form, there are other setup steps that have to be performed in order to use the two above fiields?                                                                                                                                                                                                                                                                                                                           

  • How to calculate total for field for particular day. in smart forms

    hi,
             pls help in this problem,
    how to calculate cumulative totals for the particular field in samrtforms

    Hi ,
    Either you can calculate the sum in driver program with
    Loop at where Condition .
    Sum the required field .
    endloop .
    Then pass it to smartforms
    Or
    Double Click on table node .
    In the conditions tab give the required condition .
    select calculation tab.
    In operation select Total , in field name give the name of the field you want to sum
    and in targer field name specify the name of the field that should contain the result .
    To convert the total in to words use the function module in program lines
    CALL FUNCTION 'HR_IN_CHG_INR_WRDS'
    EXPORTING
    amt_in_num = w_total
    IMPORTING
    AMT_IN_WORDS = w_total_words
    EXCEPTIONS
    DATA_TYPE_MISMATCH = 1
    OTHERS = 2
    Regards

  • How do I subtract two fields in a form?

    I am working on an expense form and I have everything working except one thing.
    We have to subtract any over payments from previous expense reports on the current expense report. I am looking at the calculate tab of the Text Field Properties.  But I do not see a way to subtract my two fields.
    I then setup a field that contains a negative one, except when I display the field on the form, the negative one is a positive one.  I did enter -1 as the default value to my "subtraction" field.  I was then going to multiple negative 1 against the the over payment amount so I could get a negative over payment amount.  I was then going to add the negative over payment amount to the total due and arrive at a net due,  But this does not work.
    Here is the calculation I am trying to do:
    Total Expenses     (calculated field from all of the preceding fields.)
    Deductible Expense       (user entered)
    Net Expense check          (Total Expense - Deductible expense).
    Can anyone tell me how to do this?
    thanks,
    Dennis

    With Acrobat there are 3 calculations options.
    "The field is the ____ of the following fields:" options are for sum, product, average, min, and max operations or for actions that could be repeated over multiple fields. One does not usually subtract or divide multiple fields in on action.
    "Simplified field notation" uses only field names and values. Field names must start with an alphabetic character and should not have any spaces or special characters. Cannot perform conditional control statements or functions. Special characters or spaces can be in field names if the JavaScript escape character precedes the special character or space. The 4 arithmetic operations can be performed.
    "Custom JavaScript calculation" has no restrictions on field names, control statements, functions or mathematical operations. One needs to access the field object and the value property of the field object.

  • How to calculate sum of the fields in adobeforms

    Hello Experts
    can  i know how to calculate sum of fields in the adobe form.  I have few fields to be summed in total field.
    Regards

    Hello Surendra,
         Suppose you are having 4 fields and the 4th field is the TOTAL field.
         Write the below Javascript on the Initialize event of TOTAL field as shown below.
    Remember that if you use just "+" sign without Number() or ParseInt() function it acts like String Concatenation.
    this.rawvalue = Number( this.parent.field1.rawvalue ) +
                          Number( this.parent.field2.rawvalue ) +
                          Number( this.parent.field3.rawvalue ) ;
    You can also write is as shown below.
    this.rawvalue = parseInt( this.parent.field1.rawvalue ) +
                             parseInt( this.parent.field2.rawvalue ) +
                             parseInt( this.parent.field3.rawvalue ) ;

  • I am working in Adobe Acrobat 9 Pro and just created a pdf form from a MS Word document. I need to find out how to have a date field in my form which will update automatically. Can some one out there help me?

    I am working in Adobe Acrobat 9 Pro and just created a pdf form from a MS Word document. I need to find out how to have a date field in my form which will update automatically.

    Update automatically under which circumstances, exactly?

  • How does APEX check for null values in Text Fields on the forms?

    Hello all,
    How does APEX check for null values in Text Fields on the forms? This might sound trivial but I have a problem with a PL/SQL Validation that I have written.
    I have one select list (P108_CLUSTER_ID) and one Text field (P108_PRIVATE_IP). I made P108_CLUSTER_ID to return null value when nothing is selected and assumed P108_PRIVATE_IP to return null value too when nothign is entered in the text field.
    All that I need is to validate if P108_PRIVATE_IP is entered when a P108_CLUSTER_ID is selected. i.e it is mandatory to enter Private IP when a cluster is seelcted and following is my Pl/SQL code
    Declare
    v_valid boolean;
    Begin
    IF :P108_CLUSTER_ID is NULL and :P108_PRIVATE_IP is NULL THEN
    v_valid := TRUE;
    ELSIF :P108_CLUSTER_ID is NOT NULL and :P108_PRIVATE_IP is NOT NULL THEN
    v_valid := TRUE;
    ELSIF :P108_CLUSTER_ID is NOT NULL and :P108_PRIVATE_IP is NULL THEN
    v_valid := FALSE;
    ELSIF :P108_CLUSTER_ID is NULL and :P108_PRIVATE_IP is NOT NULL THEN
    v_valid := FALSE;
    END IF;
    return v_valid;
    END;
    My problem is it is returning FALSE for all the cases.It works fine in SQL Command though..When I tried to Debug and use Firebug, I found that Text fields are not stored a null by default but as empty strings "" . Now I tried modifying my PL/SQL to check Private_IP against an empty string. But doesn't help. Can someone please tell me how I need to proceed.
    Thanks

    See SQL report for LIKE SEARCH I have just explained how Select list return value works..
    Cheers,
    Hari

  • How to create a report in Form line Style and can display Image field?

    Hi,
    In Report builder 10g, I would like to create a Report with Form Line Style and this report included a Image field.
    I can choose this Style only when Select Report type is Paper Layout. Because, If I choose Create both Web & Paper Layout or Create Web Layout only then in the next Style tab 03 option Form, Form letter and Mailing Label be Disabled.
    But in Paper Layout, my report can not display Image field.
    I tried with Web layout and all the other Styles (Except 03 mentioned be Disabled) then all Styles are displayed Imager field OK.
    How to create a report in Form line Style and can display Image field?
    I was change File Format property of my Image field from text to Image already in Property Inspector. But report only showed MM for my Image field.
    Thanks & regards,
    BACH
    Message was edited by:
    bachnp

    Here you go..Just follow these steps blindly and you are done.
    1) Create a year prompt with presentation variable as pv_year
    2) Create a report say Mid report with year column selected 3 times
    - Put a filter of pv_year presentation variable on first year column with a default value say @{pv_year}{2008}
    - Rename the second time column say YEAR+1 and change the fx to CAST(TIME_DIM."YEAR" AS INT)+1
    - Rename the second time column say YEAR-1 and change the fx to CAST(TIME_DIM."YEAR" AS INT)-1
    Now when you will run Mid Report, this will give you a records with value as 2008 2009 2007
    3) Create your main report with criteria as Year and Measure col
    - Change the fx for year column as CAST(TIME_DIM."YEAR" AS INT)
    - Now put a filter on year column with Filter based on results of another request and select these:
    Relationship = greater than or equal to any
    Saved Request = Browse Mid Report
    Use values in Column = YEAR-1
    - Again,put a filter on year column with Filter based on results of another request and select these:
    Relationship = less than or equal to any
    Saved Request = Browse Mid Report (incase it doesn't allow you to select then select any other request first and then select Mid Report)
    Use values in Column = YEAR+1
    This will select Year > = 2007 AND Year < = 2009. Hence the results will be for year 2007,2008,2009
    This will 100% work...
    http://i56.tinypic.com/wqosgw.jpg
    Cheers

  • How to copy text from Excel to a text field in the form?

    Hi All,
    I want to copy a text from Excel or Word file and paste it in a text field in the form, How?
    I tried to use ctrl+c for copy and ctrl+v for paste but it doesn't work!

    hi, i've seen this problem before but can't remember what the solution was...
    but just by searching on this forum resulted in this link
    Re: Copy and Paste
    hope it helps

  • How can I export a PDF form and the filled in fields to a text document?

    OK, so I have a situation.  I need people to be able to open a reader-enabled PDF form, fill out the form fields, and then export the filled-out PDF form to a basic text document.  This seems easy since Adobe Reader can save to text.  The problem is, the answers in the form fields do not show in the text file!  Each radio button shows as yes and no, and there is no indication in the text file which one was selected.  In addition, the form fields are not exported next to the questions on the form.  I tried flattening the form in Adobe pro, and that did not work either.
    How can I create a fillable form for Adobe Reader, and then let the user export their answers AND the questions on the form to plain text?

    OK, so I tried this as a starting point, and assigned it to a button on page 3 of the form.
    p=0;
    console.show();
    console.clear();
    for (var j = 0; j < this.getPageNumWords(p);j++) {
          var word = this.getPageNthWord(p,j,false);
          console.println(word);
    This gives me all the words on the first page not in fields, and each word goes on a separate line.  Now, characters in the document such as "&" or ")" cause the rest of the word to go on the next line down.
    Next, I tried this:
    console.show();
    console.clear();
    for (var j = 0; j < this.getPageNthWord(j);j++)
          var word = this.getPageNthWord(j,false);
          console.println(word);
    This only gives me the first word on page 3, the page the button is placed?
    What I need to do is run the code and place words on one line until the code hits a keyword "var cKeyWord1 = “Key1” for example?, then insert the value of field one, Start a new line in the console, restart the code where it left off until it hits the next key word "var cKeyWord2 = “Key2”, insert the value of field two, add a new line, and on and on.
    Is this possible?

  • How do I calculate averages in a form?

    Hi All,
    I'm throwing myself on the mercy of the forum.
    I'm new to form building and I don't know javascript.
    I'm working on a form and I can't seem to get it right.
    When I first enter values it seems to be working, but if I make corrections or changes the calculations go bad.
    I'm sure there is an easier/better way to calculate averages in a form.
    I think I need either a calculate/re-calculate button, or better javascript that processes the math line by line.
    I'm getting too close to the deadline to keep futzing around with it.
    Would anyone care to have a look at my form and help me?
    Here are the details...
    I'm using Acrobat 9 Pro
    I, and the administrators, are using Adobe Reader X. (10.1.4)
    I'm using a Macintosh running OS X (10.7.4, Lion)
    Teacher Evaluation Form:
    Teachers demonstrate proficiency in four domains.
    Evaluators assign scores (-, N, 0, 1, 2, and 3) to a number of items in each domain.
    N indicates the item is Not Applicable.
    A dash - indicates a score hasn't been given yet.
    Each domain has a weight value to be calculated into the final score.
    My job is to create a form that calculates the raw average and the weighted score for each domain, then a total for the performance evaluation total.
    What I did.
    I created:
    A drop down field to score each item under each domain.
    A hidden field that decides if the field for each item has a true number or another character.
    A hidden field that sums the scores of all the items in each domain.
    A hidden field that sums the number of fields that have a numeric value.
    A field that divides the total of the values from each domain and divides it by the number of of fields with numeric values to get the raw average.
    A field that multiplies the raw average by the appropriate amount to get the weighted score for each domain.
    Finally, a field that sums the weighted scores to produce the final evaluation total.
    Again, it seems to work at first, but if any changes are made to the scores the math goes bad.
    Here is a download of the form with all the hidden fields visible so you can see what is happening.
    https://dl.dropbox.com/u/783012/2_Evaluation%20Form.pdf
    Please help me!

    There are several problems with the calculation script for the "Test Total" field. Be sure to have the following user preference set: Edit > Preferences > JavaScript > Show console on errors and messages.
    Also check that the field calculation order is correct.

  • How to show a time field in a form portlet

    Hi,
    I am not familiar with PL/SQL and I was wondering how I could show a time field on a form portlet.
    I have a date column in my database that stores the time and date together, but I do not know how to separate them into date and time fields. I also do not know how to concatenate them when a user inserts a new record, or how to query on a date alone.
    At present, the user has to type the date and time following this format mask hh:mi am DD/Mon/RR
    I also have a problem with one of my hidden id fields. I have set the default to a sequence.nextval (#qtc_app.seq_visitor.nextval) and then hidden it since
    it is irrelevant to my users. However, I can no longer use the query function since the sequence is always generating a new value. How would I only generate
    a new sequence no. when a user inserts a record??
    Thank you!
    cheers, Kim

    Hi,
    Each colunm in the form has a format mask associated with it. For the date column make the format mask like this DD-MON-RR HH.MI. This will show the date along with the hours and minutes.
    Thanks,
    Sharmila

  • How to encrypt the text in password field in Oracle Forms version 6i

    Need help!
    How to encrypt the text in password field in Oracle Forms version 6i?
    one way is to change the settings in the property palette. Can somebody provide me some script to be run while the form is running which will enable the password to be encrypted?
    Thanks!

    Hello,
    Do you mean "hidden" (replaced with stars) or encrypted (that needs to be decrypted ?
    Francois

Maybe you are looking for

  • Problems with Macbook Pro 2,2 DVI to Samsung Plasma 40'' HDMI

    Hi all, sorry if this sounds familiar, just want to check I've done everything. Essentially, I'm attempting to connect the DVI (NOT Mini-DVI) output on my MacBook Pro 2,2 to the HDMI port (labelled HDMI2/DVI) input on my Samsung TV using this cable:

  • Critical issue - delta queues for LIS empty after upgrade BW3.5

    The delta queue in R/3 for LIS sources (S260-261-262) remains empty, even after a successful init delta. Hence I cannot extract delta records. BW3.5 PI2004.1 Does the BW upgrade has an effet on the delta queue management in R/3 ? The previous configu

  • Solaris 10 x86 patching, ethernet stopped working

    Hello, This morning I ran smpatch download, install in single user mode. Rebooted, and my ethernet has stopped working on elxl0 3com 90XX LAN driver. There does not appear to be any problems in dmesg. Anyone having similar problems? I have been keepi

  • An error occured in UI Component

    Hello               I'm working on the CRM WEB-UI , I have created search page where I have created hyperlink to view the overview page.               Initially in overview page i have added the two views table view and form view ,Later i have change

  • How to save/archive full project

    Cant seem to find a way to save project with an asset folder. most programs give you a choice to gather all included pictures, video, audio, etc and save it in a folder with the project. Does keynote only save as ONE big file? ive tried everything in