Create Calculated Field in PHP Form

Hi,
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));
//-->
</script>
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,
    Pete

  • 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.
    Regards
    Karan

    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....
    Eg:
    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.
    Regards,
    Karan

  • 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.
    Greetings.
    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 = com.sap.pct.hcm.isrdispatcher.default.  I'm following the UWL item type guide for this at:
    http://help.sap.com/saphelp_nw04s/helpdata/en/b1/cc1357eead454bb144face4a66be7d/content.htm
    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,
    Russell.

  • 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:
    http://blog.pathtosharepoint.com/2008/09/01/how-to-open-hyperlinks-in-a-new-window-or-not/,  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

    Hi,
    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.
    Thanks!

    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.
    Regards
    Prakash

    http://technology.amis.nl/blog/3315/creating-an-adf-application-based-on-plsql-api-part-one-reading-data-as-a-collection-of-sql-type-objects
    Hope this will help.
    ~Krithika

  • Create Calculator with the InfoPath Form Web Part

    Hi,
    I have gone through these steps
    https://msdn.microsoft.com/en-us/library/office/ee559624(v=office.14).aspx#sectionSection1
    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?
    Thanks!

    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,
    Kevin
    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?
    Thanks
    Regards
    Gorge

    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!
    Regards,
    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.
    Bernd

  • 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:
    topmostSubform
    The first field I need to calculate is a percent field;
    name:
    Current_Percent1
    fields needed for calculation:
    Current_Salary1/Current_CIP1
    so Current_Percent1=Current_Salary1/Current_CIP1
    I tried this on the script editor but it didnt work:
    Current_Percent1.=(topmostSubform.Current_Salary1/topmostSubform.Current_CIP1)
    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.
    Thanks

  • Calculated field with decimal place

    Hello,
    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)
    How?
    Thanks

    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