Extracting the total in dollars from a form

Hi,
I have a order form with fields for 5 products, each product can be ordered in single qty or a case with a sub total field plus a grand total and I'm trying to figure out how to extract the total & grand total amounts (in dollars) into the php form handler file so the amounts are sent back to the visitor and the site owner.
Thanks in advance

I searched around this morning and found the below javascript from http://www.mcfedries.com/javascript/ordertotals.asp which I adapted below for the wines selections. No styling but I think it has possibilities and more than one wine selection can be chosen.
Only thing I can't get the script to do is write the 'order_total' to a form input field which could then be collected via php and sent to the email address. At moment the script writes the total to <div>
<div id="order_total" style="text-align: right">$0.00</div>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Calculating Order Form Totals in  JavaScript</title>
<style>
input {
    width: 60px;
#orderForm {
    width: 600px;
    margin: 0 auto;
</style>
</head>
<script language="JavaScript" type="text/javascript">
<!--
/* This script is Copyright (c) Paul McFedries and
Logophilia Limited (http://www.mcfedries.com/).
Permission is granted to use this script as long as
this Copyright notice remains in place.*/
function CalculateTotal(frm) {
    var order_total = 0
    // Run through all the form fields
    for (var i=0; i < frm.elements.length; ++i) {
        // Get the current field
        form_field = frm.elements[i]
        // Get the field's name
        form_name = form_field.name
        // Is it a "product" field?
        if (form_name.substring(0,4) == "PROD") {
            // If so, extract the price from the name
            item_price = parseFloat(form_name.substring(form_name.lastIndexOf("_") + 1))
            // Get the quantity
            item_quantity = parseInt(form_field.value)
            // Update the order total
            if (item_quantity >= 0) {
                order_total += item_quantity * item_price
    // Display the total rounded to two decimal places
    document.getElementById("order_total").firstChild.data = "$" + round_decimals(order_total, 2)
function round_decimals(original_number, decimals) {
    var result1 = original_number * Math.pow(10, decimals)
    var result2 = Math.round(result1)
    var result3 = result2 / Math.pow(10, decimals)
    return pad_with_zeros(result3, decimals)
function pad_with_zeros(rounded_value, decimal_places) {
    // Convert the number to a string
    var value_string = rounded_value.toString()
    // Locate the decimal point
    var decimal_location = value_string.indexOf(".")
    // Is there a decimal point?
    if (decimal_location == -1) {
        // If no, then all decimal places will be padded with 0s
        decimal_part_length = 0
        // If decimal_places is greater than zero, tack on a decimal point
        value_string += decimal_places > 0 ? "." : ""
    else {
        // If yes, then only the extra decimal places will be padded with 0s
        decimal_part_length = value_string.length - decimal_location - 1
    // Calculate the number of decimal places that need to be padded with 0s
    var pad_total = decimal_places - decimal_part_length
    if (pad_total > 0) {
        // Pad the string with 0s
        for (var counter = 1; counter <= pad_total; counter++)
            value_string += "0"
    return value_string
//-->
</script>
<body>
<div id="orderForm">
<form>
<table width="600" cellspacing="0" cellpadding="0" border="0">
<tr>
<td width="200">Type of vine</td>
<td width="80">Number<br>
of single bottles</td>
<td>Price<br>per<br>bottle</td>
<td width="80">Number<br>of full<br> cases</td>
<td>Price<br>per<br>case</td>
</tr>
<tr>
<td><input type="checkbox" name="chardonnay_2011" id="chardonnay_2011" />Chardonnay 2011</td>
<td><Input type="text" name="PROD_Chardonnay2011Bottles_20.00" onChange="CalculateTotal(this.form)"></td>
<td>$20.00</td>
<td><Input type="text" name="PROD_Chardonnay2011Cases_204.00" onChange="CalculateTotal(this.form)"></td>
<td>$204.00</td>
</tr>
<tr>
<td><input type="checkbox" name="pinoGris_2011" id="pinoGris_2011" />Pino Gris 2011</td>
<td><Input type="text" name="PROD_PinoGris2011Bottles_21.00" onChange="CalculateTotal(this.form)"></td>
<td>$21.00</td>
<td><Input type="text" name="PROD_PinoGris2011Cases_228.00" onChange="CalculateTotal(this.form)"></td>
<td>$228.00</td>
</tr>
<tr>
<td><input type="checkbox" name="sauvigonBlanc_2011" id="sauvigonBlanc_2011" />Sauvigon Blanc 2011</td>
<td><Input type="text" name="PROD_SauvigonBlanc2011Bottles_20.00" onChange="CalculateTotal(this.form)"></td>
<td>$20.00</td>
<td><Input type="text" name="PROD_SauvigonBlanc2011Cases_204.00" onChange="CalculateTotal(this.form)"></td>
<td>$204.00</td>
</tr>
<tr>
<td><input type="checkbox" name="riesling_2012" id="riesling_2012" />Riesling 2012</td>
<td><Input type="text" name="PROD_Riesling2012Bottles_20.00" onChange="CalculateTotal(this.form)"></td>
<td>$20.00</td>
<td><Input type="text" name="PROD_Riesling2012Cases_204.00" onChange="CalculateTotal(this.form)"></td>
<td>$204.00</td>
</tr>
<tr>
<td><input type="checkbox" name="pinoNoir_2009" id="pinoNoir_2009" />Pinot Noir 2009</td>
<td><Input type="text" name="PROD_PinotNoir2009Bottles_25.00" onChange="CalculateTotal(this.form)"></td>
<td>$25.00</td>
<td><Input type="text" name="PROD_PinotNoir2009Cases_250.00" onChange="CalculateTotal(this.form)"></td>
<td>$250.00</td>
</tr>
</table>
<input style="width: 120px;"  type="reset" reset value="clear form">
</form>
<div style="text-align: right">Total:</div>
<div id="order_total" style="text-align: right">$0.00</div>
</div>
</body>
</html>

Similar Messages

  • [svn:osmf:] 14486: Add stream metadata support by extracting the actual metadata object from the binary data stream .

    Revision: 14486
    Revision: 14486
    Author:   [email protected]
    Date:     2010-03-01 14:27:41 -0800 (Mon, 01 Mar 2010)
    Log Message:
    Add stream metadata support by extracting the actual metadata object from the binary data stream.
    Fix bug 466
    Modified Paths:
        osmf/trunk/framework/OSMF/org/osmf/elements/f4mClasses/ManifestParser.as
        osmf/trunk/framework/OSMF/org/osmf/elements/f4mClasses/Media.as
        osmf/trunk/framework/OSMF/org/osmf/net/httpstreaming/HTTPStreamingUtils.as
        osmf/trunk/framework/OSMF/org/osmf/net/httpstreaming/f4f/HTTPStreamingF4FIndexHandler.as
        osmf/trunk/framework/OSMF/org/osmf/net/httpstreaming/f4f/HTTPStreamingF4FStreamInfo.as

    same problem, data not replicated.
    its captured,propagated from source,but not applied.
    also no apply errors in DBA_APPLY_ERROR. Looks like the problem is that LCRs propagated from source db do not reach target queue.can i get any help on this?
    queried results are as under:
    1.at source(capture process)
    Capture Session Total
    Process Session Serial Redo Entries LCRs
    Number ID Number State Scanned Enqueued
    CP01 16 7 CAPTURING CHANGES 1010143 72
    2. data propagated from source
    Total Time Executing
    in Seconds Total Events Propagated Total Bytes Propagated
    7 13 6731
    3. Apply at target(nothing is applied)
    Coordinator Session Total Total Total
    Process Session Serial Trans Trans Apply
    Name ID Number State Received Applied Errors
    A001 154 33 APPLYING 0 0 0
    4. At target:(nothing in buffer)
    Total Captured LCRs
    Queue Owner Queue Name LCRs in Memory Spilled LCRs in Buffered Queue
    STRMADMIN STREAMS_QUEUE 0 0 0

  • How to extract the actual XML document from soap message?

    My problem is " how to extract the actual XML document from soap message? "
    i just want to extract the attachment i.e. (pure XML document without any soap header or envolope).
    i could be ver thank full if u could solve my problem.
    [email protected]

    Hi,
    This is some skeleton code for extracting an attachment from a SOAPMessage.
    import javax.activation.DataHandler.;
    import javax.xml.soap.*;
    import javax.xml.message.*;
    Iterator allAttachments = message.getAttachments();
    AttachmentPart ap1 = null;
    while(allAttachments.hasNext()){
    ap1 = (AttachmentPart)allAttachments.next();
    //Check that the attachment is correct one. By looking at its mime headers
    //Convert the attachment part into its DOM representation:
    if(ap1.getContentType() == "text/xml"){
    //Use the activation dataHandler class to extract the content, then create a StreamSource from
    //the content.
    DataHandler attachmentContent = ap1.getDataHandler();
    StreamSource attachmentStream = new StreamSource(attachmentContent.getInputStream());
    DOMResult domAttachment = getDOMResult(attachmentStream);
    domAttachment holds an xml representation of the attachment.
    Hope this helps.

  • How to extract the license plate region from the image of cars

    HI, I want to extract the license plate region from the image of cars with vision assistant. I try to adjust the threshold value, remove small objects. But i still cannot get the perfect license plate region. I have attached 4 images that i am working now. I hope someone can help me to extract that region. Really thanks.
    Attachments:
    IMG_2029.JPG ‏150 KB
    IMG_2031.JPG ‏155 KB
    IMG_2089.JPG ‏130 KB

    Hi, I have attached my extrated images.. Please check them...
    Attachments:
    35.PNG ‏17 KB
    36.PNG ‏12 KB
    37.PNG ‏13 KB

  • How to extract  the date n time from images

    can anybody help me...what function/ method that i can use to extract the date an time from images
    thanks

    Hi norazanita,
    Please give clear idea what you want so one can proceed.
    And if i am not wrong and get you correctly than i think you need to read about OCR for JAVA.
    Regards,
    Joshi Shirin.

  • I can't extract the msi and files from the 11.0.02.exe it is asking for a password!

    I can't extract the msi and files from the 11.0.02.exe it is asking for a password!!!!  Help

    From where did you download the exe?
    How exactly are you trying to extract it?

  • How to extract the Financial statement version from R/3 to BW

    Hi all,
    I've used the business content to extract the details of SAP R/3 G/L account details to BW. Now, I need to extract the Financial statement version also from R/3 to SAP. Is there any business content object available for the same?
    Thanks in advance,
    Sam.

    Use cube: 0FIGL_C01 with 0GL_ACCOUNT. Load the text and attributes for 0GL_ACCOUNT and the hierarchy based on FSVs in R/3.Build your Balance Sheets and Income Statemments in this.
    If your FSV has balance dependancies: say if the accounts in the FSV move from one node to another depending on their balance at run time, then you will have to use the virtual cube (0FIGL_VC1) along with info-object 0GLACCEXT. However from my experience with VC1, there are a lot of restrictions and inconsistencies that you will have to contend with while working with this cube.
    Cheers
    Anand

  • How to get the total execution time from a tkprof file

    Hi,
    I have a tkprof file. How can I get the total execution time. Going through the file i guess the sum of "Total Waited" would give the total time in the section "Elapsed times include waiting on following events:"
    . The sample of tkprof is given below.
    SQL ID: gg52tq1ajzy7t Plan Hash: 3406052038
    SELECT POSTED_FLAG
    FROM
    AP_INVOICE_PAYMENTS WHERE CHECK_ID = :B1 UNION ALL SELECT POSTED_FLAG FROM
      AP_PAYMENT_HISTORY APH, AP_SYSTEM_PARAMETERS ASP WHERE CHECK_ID = :B1 AND
      NVL(APH.ORG_ID, -99) = NVL(ASP.ORG_ID, -99) AND
      (NVL(ASP.WHEN_TO_ACCOUNT_PMT, 'ALWAYS') = 'ALWAYS' OR
      (NVL(ASP.WHEN_TO_ACCOUNT_PMT, 'ALWAYS') = 'CLEARING ONLY' AND
      APH.TRANSACTION_TYPE IN ('PAYMENT CLEARING', 'PAYMENT UNCLEARING')))
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute    442      0.08       0.13          0          0          0           0
    Fetch      963      0.22       4.72        350      16955          0         521
    total     1406      0.31       4.85        350      16955          0         521
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 173     (recursive depth: 1)
    Number of plan statistics captured: 1
    Rows (1st) Rows (avg) Rows (max)  Row Source Operation
             1          1          1  UNION-ALL  (cr=38 pr=3 pw=0 time=139 us)
             1          1          1   TABLE ACCESS BY INDEX ROWID AP_INVOICE_PAYMENTS_ALL (cr=5 pr=0 pw=0 time=124 us cost=6 size=12 card=1)
             1          1          1    INDEX RANGE SCAN AP_INVOICE_PAYMENTS_N2 (cr=4 pr=0 pw=0 time=92 us cost=3 size=0 card=70)(object id 27741)
             0          0          0   NESTED LOOPS  (cr=33 pr=3 pw=0 time=20897 us)
             0          0          0    NESTED LOOPS  (cr=33 pr=3 pw=0 time=20891 us cost=12 size=41 card=1)
             1          1          1     TABLE ACCESS FULL AP_SYSTEM_PARAMETERS_ALL (cr=30 pr=0 pw=0 time=313 us cost=9 size=11 card=1)
             0          0          0     INDEX RANGE SCAN AP_PAYMENT_HISTORY_N1 (cr=3 pr=3 pw=0 time=20568 us cost=2 size=0 card=1)(object id 27834)
             0          0          0    TABLE ACCESS BY INDEX ROWID AP_PAYMENT_HISTORY_ALL (cr=0 pr=0 pw=0 time=0 us cost=3 size=30 card=1)
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      db file sequential read                       350        0.15          4.33
      Disk file operations I/O                        3        0.00          0.00
      latch: shared pool                              1        0.17          0.17
    ********************************************************************************

    user13019948 wrote:
    Hi,
    I have a tkprof file. How can I get the total execution time.
    call count cpu elapsed disk query current rows
    total 1406 0.31 4.85 350 16955 0 521TOTAL ELAPSED TIME is 4.85 seconds from line above

  • Report to extract the total Amount that we spent for materials

    Hi Guru's,
    I was trying to find a report that gives all the following information by Company Code. Out put should have the following fields:
    1)Vendor Name,
    2) Vendor Number,
    3)Company Code,
    4) Payment Terms Code From Vendor Master,
    5) Payment Terms Description,
    6)Material Number,
    7)Material Description and
    8) Amount Spend for last 12 months
    I would appreciate any inputs on these kind of reports.
    Thanks
    Nath..........

    Sridhar,
    Thanks for your response but I am not getting Material number using report FBL1N and also I in the amount column I was looking for the total amount (total spent during the whole year) by Vendor, Company Code and Material. I am trying to execute this for three different company codes. So, will FBL1N work for us to get these total amounts.
    Thanks
    Nath

  • Sql Query need to extract the Work Flow information from Hyperion Planning

    Can Any one give me the sql query to extract the Work flow from Hyperion Planning in 11.1.2.1.
    I can extract from the Hyperion Planning but it is not in required format again I need to do lot of formating. I need the information as per the flow structure is showing linke in one perticular planning unit in all coloumn format. Hence only sql query will help me to extract this kind of information. could any one provide the sql query to extract this kind of request.
    Thanks in Advance.
    Edited by: 987185 on Feb 9, 2013 10:57 PM

    If you have a look at the data models in - http://www.oracle.com/technetwork/middleware/bi-foundation/epm-data-models-11121-354684.zip
    There is the structure of the planning application tables, have a look at the HSP_PM_* tables
    Alternatively you can look at extracting the information using LCM.
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • Want to get the Client Machine name from Oracle Forms

    Hi,
    I want to get the Client machine name from the Oracle Forms.
    I have attached web_util.pll.
    I use user_name := webutil_clientinfo.get_host_name;
    but i am getting following error - WebUtil Error:WUC-015: Your form must contain the following Bean for this function to be available: oracle.forms.webutil.clientinfo.GetClientInfo.
    Can any one help me in this!
    Thanks & Regards,
    Avinash Bhamare.
    Pune.

    Hi,
    I have written the code on when-button-pressed trigger of a push button -
    DECLARE
         user_name VARCHAR2(50);
    BEGIN
    user_name := client_win_api_environment.get_computer_name;
    message('user_name is :'||user_name);
    message('user_name is :'||user_name);
    END;
    And on clicking on this button i am getting error -
    frm-40734:Internal Error:PL/SQL error occurred
    Can any one help in this asap please!
    Thanks & Regards,
    Avinash.

  • How to extract the size and date from a given file

    Hi,
    I want to extract the size and date of a file (it can be either a video, audio or text file) that the user points to the location of. But I am not sure how. Does Java have an api that can do this? If not is there some other way of doing this? Can anyone help? Thanks in advance.

    Have a look at java.io.File, specifically
    public long lastModified()
    This format returned (I find) is nasty, so then use java.util.Date (or java.sql.Date, look the same on the surface to me) to format it.
    Cheers,
    Radish21

  • Extracting the tag value sent from PCo

    Hi,
    Can anybody explain how to extract the tag value hidden in a PCo notification, which is sent to a BLS transaction as an XML parameter. Appreciate it.
    Chanti.

    Guess that document only shows how to setup the communication between PCo and MII.
    Anyway I was able to extract the values once the notification is received into the BLS.
    Never mind.
    Chanti.

  • Problem in sending the report to Outlook from Oracle Forms.

    hi buddies
    I'm trying to send a report to outlook from form.
    but when I run the report with the following report parameters:
    Add_Parameter(param, 'DESFORMAT', TEXT_PARAMETER, 'pdf');
    Add_Parameter(param, 'DESNAME' , TEXT_PARAMETER,'d:\main\abc.pdf');
    Add_Parameter(param, 'DESTYPE' ,TEXT_PARAMETER,'mail');
    it gives the following message before opening the outlook:
    "c:\program files\common files\system\msmapi\1033\mpa03240
    cannot create output file. check to ensure path and file name are correct."
    then it opens a dialog box of outlook asking the cotacts whom I wanna mail this file and then opens outlook with the above mentioned report file but with a default file name like "Report.pdf" and it doesn't show the send mail button in opened outlook window.
    can u tell me the reason why is it giving this message n where is the error?

    Hi Vengal !
    What is your module configuration in comm channel ??
    what is your current result and the expected one.
    Regards,
    Matias.

  • How to extract the a date field from a text value?

    Hi,
                                      SAMLE TEXT       Date: 06-FEB-14 02:47:07
    I have sample column in flat file like mentioned above, i need to capture only the date from this column. Can anyone please help me on how to extract this date from the column?

    Dear Mohammed Shariff,
    My suggestion is check it in google you can find no.of formulas related to excel.
    Ur's
    Mohan

Maybe you are looking for

  • How to interpolatin in java regular expression

    Hello, I am having a problem regarding variable interpotaion in java regex. i am having a pattern file . This is one of my Pattern from pattern file (\{NP_PP_[0-9]+\}|\{NP_B_[0-9]+\}|\{NP_P_[0-9]+\}|\{NP_[0-9]+\})[^{}]*PHOSphorylatable amino[^{}]*(\{

  • Show Notifications in Air - Flash Builder 4.6

    Hi, I'm new into Flash Builder mobile apps development. I just downloaded the latest release of Flash Builder, the 4.6. I read in this Adobe's article, that with this version I can add "Notifications" to my apps. I tried to, but all my experiments fa

  • Adobe Flash Player 11 plugin not working right

    I have Adobe Flash Player 11 Plugin, Widows Internet Explorer 8 and Microsoft Windows XP, version 5.1.2600.  Why is it not dowloading pictures?

  • R/3 is  locking when BW loads triggers

    Hi Experts, We have a severe performance problem with R/3 whenever BW jobs scheduled to bring the data from R/3. Can anyone through some ideas why this is happening? Thanks & Regards, VSN. Message was edited by:         vsn

  • Process flow - Integrating all modules

    Hi All I have been working in SAP BI for the last 4 years. I want to gain a integrated perspective of the process flow in SAP. It would help me if someone can pass on any document which outlines the big picture. How things flow and are integrated bet