Create Calculated Field in PHP Form

I'm trying to create a calculated field that will work out the average of ratings given during the input of a form. This field will then submit the average value with the form at the end (which is why I need the value to calculate before the form submits - i.e., as the form is filled in).
I have found the following code (designed for HTML forms rather than PHP forms, but I'm hoping it might work). It doesn't seem to do anything - the field doesn't show any information. Help?
<script language=javascript>
function dm(amount)
  string = "" + amount;
  dec = string.length - string.indexOf('.');
  if (string.indexOf('.') == -1)
  return string + '.00';
  if (dec == 1)
  return string + '00';
  if (dec == 2)
  return string + '0';
  if (dec > 3)
  return string.substring(0,string.length-dec+3);
  return string;
function calculate()
  Opp1 = 0;  Inv1 = 0;  Com1 = 0;  wlb1 = 0;  Com2 = 0;  Atm1 = 0;  Per1 = 0;  Inc1 = 0;  Rew1 = 0;  Env1 = 0;  Gro1 = 0;
  if (document.form1.Opportunity.value > "")
     { Opp1 = document.form1.Opportunity.value };
  document.form1.Opportunity.value = eval(Opp1); 
  if (document.form1.Investment.value > "")
     { Inv1 = document.form1.Investment.value };
  document.form1.Investment.value = eval(Inv1); 
  if (document.form1.Community.value > "")
     { Com1 = document.form1.Community.value };
  document.form1.Community.value = eval(Com1); 
  if (document.form1.WLB.value > "")
     { wlb1 = document.form1.WLB.value };
  document.form1.WLB.value = eval(wlb1); 
  if (document.form1.Communication.value > "")
     { Com2 = document.form1.Communication.value };
  document.form1.Communication.value = eval(Com2); 
  if (document.form1.Atmosphere.value > "")
     { Atm1 = document.form1.Atmosphere.value };
  document.form1.Atmosphere.value = eval(Atm1); 
  if (document.form1.Performance.value > "")
     { Per1 = document.form1.Performance.value };
  document.form1.Performance.value = eval(Per1); 
  if (document.form1.Inclusion.value > "")
     { Inc1 = document.form1.Inclusion.value };
  document.form1.Inclusion.value = eval(Inc1); 
  if (document.form1.Rewards.value > "")
     { Rew1 = document.form1.Rewards.value };
  document.form1.Rewards.value = eval(Rew1); 
  if (document.form1.Environment.value > "")
     { Env1 = document.form1.Environment.value };
  document.form1.Environment.value = eval(Env1); 
  if (document.form1.Groups.value > "")
     { Gro1 = document.form1.Groups.value };
  document.form1.Groups.value = eval(Gro1); 
  Totamt =
     eval(Opp1) +
     eval(Inv1) +
     eval(Com1) +
     eval(wlb1) +
     eval(Com2) +
     eval(Atm1) +
     eval(Per1) +
     eval(Inc1) +
     eval(Rew1) +
     eval(Env1) +
     eval(Gro1) ;
  document.form1.GrandTotal.value = dm(eval(Totamt));
Any suggestions gratefully received.

@uscart - Thanks for your thoughts. I think I may try and pursue the javascript option (considering how far I've gone with it) but don't quite understand your response. Does it matter if the input field isn't a text box? The fields are radio buttons (giving options 1-10), liek so:
  <input name="Investment" type="radio" class="star" value="1"/>
  <input name="Investment" type="radio" class="star" value="2"/>
  <input name="Investment" type="radio" class="star" value="3"/>
  <input name="Investment" type="radio" class="star" value="4"/>
...etc, etc, etc... for each of the input fields listed above.
Where do I put the calculate() function? After each "option", or is there a different reference? And does it need to be added to the GrandTotal field as well (the field in which the calcualtion is to be displayed)?
Thank you!

Similar Messages

  • Can I create calculated fields using formscentral on a locally created, fillable PDF form?  If so, how?

    I am using Acrobat XI Pro to build a fillable PDF form that can be used by customer who have Adobe Reader installed.  I would like to create calculated fields, including the summation of two or more currency fields and the product of a currency and number field.  The procedure for creating these escapes me.  Does anyone have any insight?

    Hi Gilad,
    thankyou! - yes it seems though I was using the text tool when I had this problem: When I had created a few fields in the 'form edit' mode I then may later have added some normal 'comment' fields of text in the normal mode to highlight certain aspects on a form - I used the text tool thinking that was the right way in to add or edit text - I can now see I double click with the hand tool to still be able to access any text field I want to. Yay!
    Many thanks for your kind assistance - I shall try this method later on a new form I was trying to create and which was giving me grief.
    One last thing then: what is that default text field that can't be deleted actually for - why is it there? After all, a 'blank pdf' should surely be a truly blank pdf? Perhaps this is one for mighty Adobe....?
    Kind Regards,

  • How to create Lookup field in user form in OIM 11g - Urgent

    Hi Experts,
    How to create Lookup field in User Form - OIM 11g.
    Pls. provide your support on priority.

    Thanks all for your suggestion.
    Our requirement, is we need to have a user defined field similar to how its there in "Organisation".
    For example we need to create an user defined field like "Service Holding" which holds different services say like Service 1, Service 2, Service 3 etc.
    Under each service there are multiple roles....
    Service 1 - Role 1, Role 2, Role 3
    Service 2 - Role 4, Role 5
    Service 3 - Role 6, Role 7, Role 8
    Is there a way to store multi-valued attribute in OIM UDF? If so, pls. guide us
    If its not possible we would need to create a Lookup field (something similar to Organization or Manager). User clicks on the button (lens button), which should invoke an API wherein he can select specific Roles and save in User. Eg. like Service 1 - Role 1#Service 2 # Role 5 and store in the backend database.
    Is this possible. Pls. guide.

  • Calculated field in adobe forms central

    Can I make a calculated field in adobe forms central? For example a field that will sum total cost.

    Hi hacker413,
    Thank you for posting on the Adobe forums, unfortunately this facility is not available in Adobe Formscentral.
    Vikrantt Singh

  • Calculated Field In ADF Form

    I want to create calculated field.
    I have 2 date fields, my user case is to calculate difference between those 2 date field and display difference on the fly to user.

    You will need to write custom logic in a method of a managed Bean in your View Controller project.
    follow these steps -
    1)In the ViewController project ,create a java Class called <whatever_name_you want>.java
    2) register the managedBean in TaskFlow->Overview-> Managed Bean say in pageFlowScope.
    3)create a public method which returns a Number (of days or whatever you need) in your bean which calculates difference between the dates using Calender API (You can google for this)
    4)Bind this method to the value property of the field which shows the difference between these fields.

  • Problems!:  calculated fields in Adobe Forms using the ISR/PCR framework.

    Hi there,
    I have made an Adobe form in the ISR framework. Everybody who is familiar with these forms in the framework knows that the adobe form is embedded in a standard webdynpro which consist of a roadmap with three steps.
    Step 1: Fill out the form
    Step 2: Check and fill the form
    Step 3: Submit the form. After submit the form can be send to a manager or can be directly processed in SAP HR.
    Problem 1:
    When I test the adobe form and fill in a number in a field and click on next everything goes fine. But when I click on previous step the value which I filled in before is gone and put to 0,00.
    Problem 2:
    Also another problem is that calculated fields, do not show directly when clicking on next step. When you click on next step and then previous step, then you see the value of the calculated field.
    Problem 3:
    Also another problem is with the calendar function. When I fill in a date by hand and click on next the BADI behind the form sees 00-00-0000. When I use the calendar function everything goes well.
    Who can help me with these 3 problems.
    Message was edited by: Sandhya Banwarie

    Hi Phil,
       Interesting - I have a similar issue.  We want to use the Request for Transfer scenario in ERP 2005, but it has not been developed in Adobe forms by SAP yet (it isn't available in 2004 either)!  So, we have decided to use the old JSP PCRs instead.
    Your issue is probably because you're using the same 2005 iviews to create your PCRs.  The 2005 PCR iviews are written in WebDynpro, and appear to assume that each one will be an Adobe form!  If you assign the old PCR iviews to your manager (give them the old MSS role under Migrated Content->EP5.0... in the pcd if you have it installed), you will be able to create a PCR with the JSP forms (regardless of the "Entry in Web" setting in QISRSCENARIO).
    The next issue is the approval.  In 2005, transaction SWFVISU has task TS50000075 configured as Java Webdynpro.  You'll need to change that to iView, and specify ID =  I'm following the UWL item type guide for this at:
    Having said this, my approval is not working!  The item type has clearly changed, because the workitem name is no longer a hyperlink (rather annoying), but when I hit the "Launch Task Page" button (default name I think) I get the error:
    "Unable to perform action because the system returned an invalid URL"
    I can't see this "invalid url" anywhere in the logs, so I can't see where it is getting it from, or what path, etc I'm meant to put!  In your old system, what did you have as the "Server for ISR call" under "Additional Data for Scenario" in QISRSCENARIO?  Also, what did you have in the "URL" box that appears under the Additional Data for Scenario button when you change the Entry Type to JSP?
    Many thanks,

  • How to created calculated field that is a hyperlink

    I am trying to create a hyperlink in a calculated field.  The text string renders, but only part of it is a hyperlink. I used this syntax:
    https://domain/sites/itd/SBTD/TSG/General%20Documents/Forms/by%20Document%20Category.aspx?View={373A9A36-C01A-4616-BADA-065DEEBC44C0}&FilterField1=Agreement&FilterValue1=IAA 2011-12-13
    Then, based on this article:,  I tried writing it as HTML like this:
    =CONCATENATE("<a href=’”,”https://domain/sites/itd/SBTD/TSG/General%20Documents/Forms/by%20Document%20Category.aspx?View={373A9A36-C01A-4616-BADA-065DEEBC44C0}&FilterField1=Agreement&FilterValue1=",Agreement Number,”’>”,documents,”</a>”).
    That got my an error regarding illegal syntax.
    Does anyone know how to do this in the UI?
    There are no mistakes; every result tells you something of value about what you are trying to accomplish.

    Where are you trying to get the "IAA
    2011-12-13" from?
    By the look of what you are trying to do, this would read the value from a column called "Agreement Number" and embed
    it in to the URL. Do you have a column called "Agreement Number"?

  • Creating dynamic field in the form

    How to create a dynamic block?
    The item in the block could be autochanged with the changing of
    table's field.
    I don't want to rebuild the form.

    You can base a block on a from clause.
    SO base your block on something like
    select ename a, deptno b from emp;
    define 2 fields in the block a and b.
    Now you can use set_block_property to change the underlying SQL
    for example select dname a ,loc b from dept.

  • How to create text fields & assign values form sql in ADF

    Hi all,
    I am new to oracle ADF,
    i want know how to create text fileds and how to assign the values to those fields from plsql.
    Hope this will help.

  • Create Calculator with the InfoPath Form Web Part

    I have gone through these steps
    on SharePoint 2013, and everything works except only one parameter will send data.  The last one set is the only one that will work.
    Any ideas?

    Change your button not to use the Submit type but rather to use the Rules and Custom Code type, then add a rule that does a submit plus whatever other actions you're doing.  Add a Close action as well if you want, but you should also then be able
    to set the form web part to close on submit.  All of my forms are built like this, and I use them all in form web parts (I'm in love with them).
    Oh, another thing I do is when my user submits, I switch to a new view that looks nice and has a submit confirmation.  At the point, the form doesn't even need to be closed, but I do have a close button just in case.
    SharePoint Architect || Microsoft MVP ||
    My Blog

  • InDesign equivalent of LiveCycle's "Image Field" in PDF form creation?

    LiveCycle has a PDF form field called "Image Field". We add this field to the PDF files we create so that our end users can select and import a JPEG image into their PDF document using Adobe Reader.
    Now we would like to use InDesign to produce the same PDF form files as an alternative to using LiveCycle. Does InDesign have a PDF form field like LiveCycle's "Image Field"? We haven't found it yet.
    In other words, does someone know in InDesign how to create a field in PDF forms which has the same functionality as LiveCycle's "Image Field"? LiveCycle's field works in enabled Adobe Reader files, and permits JPEG format, among others.
    Thank you,
    P.S. We discovered a way to create PDF forms in Adobe Acrobat Pro XI with similar functionality by using JavaScript, but the Acrobat Pro created documents only permit Adobe Reader to import PDF files, not JPEG or other image formats. So Adobe Acrobat Pro XI was not a viable alternative to LiveCycle for creating our PDF files. We'd like to know if we need to rule out InDesign, too.

    It's worth separating out the different responsibilities and products.
    Whether a functionality exists in Reader depends on the Acrobat team. Reader, being free, is limited by design, the aim of the design being to sell copies of Acrobat. Obviously, Reader can't make PDFs or do preflighting. Less obviously, there are a bunch of JavaScript functions that don't work. Sometimes, with Reader enabling, more functions become available. (There are different kinds of Reader enabling, some of which need very expensive extra products).
    Whether a form capability exists at all is largely down to the PDF specification (now an ISO standard) or the XFA specification. Adobe can choose to go beyond the specification but largely choose not to.
    So, the InDesign team can make form fields, not because the Acrobat team approves, but because the way this is done is written down in the PDF Specification. InDesign _could_ choose to make XFA forms, but thank goodness that will never happen.
    So, if you want InDesign forms to do something you first have to ask: can Acrobat forms to this. NOT XFA (LIveCycle forms) which are done by a different team to different rules. So far as I know Acrobat forms cannot do the sort of thing you want; that is, placing arbitrary graphics, but in certain circumstances they can place PDF files.
    Why make the distinction?
    - If Acrobat can make forms that do this, then so can InDesign: it's worth asking the InDesign people to do it.
    - If Adobe limit Adobe Reader, there is no use asking the InDesign team to solve this.
    - If Acrobat can't make forms that do this, then nor can InDesign.

  • How can we add Text field on system form which is updateable?

    Hi Experts
    I Want to create text field on System Form like A/R Invoice, in which I can store value after saving the document. I means Updateable field. Is it possible and How?

    Hi Gorge,
    Please follow Jeyakanthan instructions. You may know how to create a UDF but you clealy don't understant how they work.
    A UDF in the System document's Title table is always updatable, unless you define it otherwise or do not have permission to update it (Open the form where you created the UDFs and press CTRL + ALT + B to open the definitions form).
    A UDF in the System document's Rows table is always updatable ONLY if that document's rows are updatable AND if you set them as updatable (via Form Settings) and have permission.
    On a User Form, you make your own rules!
    Vítor Vieira

  • What is better to use a calculation field or to use stored procedure

    Dear All
    i want to know what is better to use a calculation field on oracle forms , or to do the calculation using a stored procedure at the data base level and fetch the results to the fields on the form
    Best Regards

    Hello Mohannad
    the stored procedure approach might be more readable and maintainable when the calculation gets complicated.
    And it might be easier to reuse when it's needed in another part of your application.

  • Help with some calculation fields

    I'm trying to add a few calculation fields to a form but don't know how the script should be written.
    All my fields are in a form called:
    The first field I need to calculate is a percent field;
    fields needed for calculation:
    so Current_Percent1=Current_Salary1/Current_CIP1
    I tried this on the script editor but it didnt work:
    can someone help me out?

    Ok, looks like I got it. I did have it as formcalc but it looks like I wrote in too much info.
    I got it to work by setting SHOW to *caculate and adding (Current_Salary1/Current_CIP1) only
    Looks like I was making it harder than it needed to be.

  • Calculated field with decimal place

    if I create calculated field in a table using formula e.g., ColumnName/ 60, where format of ColumnName is INT (total ammount of minutes)  in order to get hours, I get only integer part, not decimal. E.g., 80 (minutes)/60 =1.3333 but, in calculated field
    I see only 1 hrs without possibility to change format of the field.
    Can calculated field be used on this way? (My wish  is to get 1.3 in that field)

    Of course the calculated field/column can not be an INT, if it is then change that.
    Does something like this work?CAST(ColumnName/60 AS Decimal(10,2))

Maybe you are looking for

  • Doughts on Infoset Joins with Cube and DSO in BI 7

    Dear All, I have a droughts on Infoset Joints. I am working on a BI Query where I need to take 0Employee from Cube and Employee position time he holds in an Organization is coming form DSO, Apart for this I also have other requirement such as Address

  • Problem deploying EAR to weblogic server

    Hi everyone I am using Jdeveloper and have deployed an ADF Fusion app to weblogic 10.3.4. I manage to deploy it but when I go to start it I get the following exception [HTTP:101216]Servlet: "weblogic.wsee.jaxws.client.async.AsyncTransportPro

  • Archiving files in the Receiver File Adapter

    Hi All, I am trying to archive the file created in the Receiver File adapter. Reading from the link below, I gave the command cp %F <target dir> in the Command

  • Context.root has not been defined

    I am trying to compile .mxml file using flex builder 3. I am using BlazeDS to run it from C:\Program Files\blazeds\tomcat\webapps\BlazeDSmsgService. I also copied the WEB-INF folder at my project folder (BlazeDSmsgService) I am getting the following

  • Updating multiple workbooks to a new substatus in performance mgmt.

    Hi I have a number of employee performance management workbooks that are all at a certain substatus right now, and I would like to be able to update them to a new substatus (basically move them back to an earlier substatus as the documents have been