How do I write JavaScript for a complex calculation in a PDF?

Is there a way to create a more complex calculation in a PDF? I have created an order form that has separate fields for quantity, price and subtotals. For every item on the order form, the first two quantities are no charge. Each quantity after that is .25/each. How do I write the JavaScript to accomplish this calculation?
e.g. 6 items ordered, first 2 are No Charge,
=(2*0.00)+(Qty-2*0.25), should equal $1.00
=(2*0.00)+(6-2*0.25)
=0.00+1.00
=1.00

Not quite. You still need to use the eval function otherwise the numbers are just strings.
Try this in the JavaScript Debugger:
var Qty = 4;
if (Qty>2) {
    var subtotal = eval ((Qty-2)*0.25);
} else {
    var subtotal = 0;
app.alert (subtotal);
Steve

Similar Messages

  • How do I write javascript for a text block to extract name from signature block?

    Hello,
    I've created a training certificate that the trainee has to sign electronically. To prevent someone from simply putting in their friends name in there and saving it; to send to their friend and help them from having to take the training and quiz I would like to write a javascript in the text block that would extract the name from their signature block and autofill the name in the text block. Is there a way to do this?

    You would have to use JavaScript to access the signature field object and then you can access the various properties of the signature depending upon the certificate or method for signing.
    signatureInfo
    console.show();console.clear();
    // Get particular info;
    var f = this.getField("Signature1");
    // uses the ppklite sig handler;
    var Info = f.signatureInfo();
    // Some standard signatureInfo properties;
    console.println("name = " + Info.name);

  • How do you write UNDO for a text item?? examples? or a REDO??

    How do you write UNDO for a text item?? examples? or a REDO??
    I created a pop-up menu with CUT, COPY, PASTE, UNDO, CLEAR for my text items.
    Using MAGIC menu type works great but there is no MAGIC for UNDO or REDO.....
    How do you write UNDO for a text item?? examples? or a REDO??
    I have Oracle Forms 6i...
    Lets say I highlight all the text in the text item, and start typing over it... then I realize OH NO it is the wrong text field...
    Now I want to UNDO the typing and get back to the previous text.
    I'd use the initial value that was populate right? How do I access that if that is correct?
    Thanks, Bill

    You can use;
    <ITEM> := Get_Item_Property(<ITEM>,DATABASE_VALUE);
    Or you will have to write a pre-text-item trigger;
    PRE-TEXT-ITEM:
    :CTRL.CURRENT_VAL := :<BLOCK>.<ITEM>
    MENU (PL/SQL):
    :<BLOCK>.<ITEM> := :CTRL.CURRENT_VAL;
    You may also want to set the item property back to ITEM_IS_VALID so that item validation does not fire again.

  • Is there a site where they will write javascript for your pdfs that you could pay them to do it.

    Is there a site where they will write javascript for your pdfs that you could pay them to do it.

    Hi timothyh,
    Adobe doesn't offer those services, but you might try looking here: Planet PDF - The PDF User Community - Debenu.
    Best,
    Sara

  • How to make a Word for Mac 2008 doc into a PDF using Acrobat Macintosh

    Any ideas how to turn a Word for Mac 2008 document into a PDF using Acrobat Pro?
    Thank you if you can help.

    In Word  2008 for Mac:
    go to Save As... from File menu.
    when window open click on Button show the current file type.
    when thi menu drops down you will see the following
    Choose PDF
    save.
    Then open up in Acrobat.

  • NEWB HELP! How do I write Formula for Sales Tax and Gratuity items

    Sorry for the bonehead question, but I'm not much good with spreadsheets and we're trying to find out if we can afford to get MARRIED. In numbers '08, I'm using the "new from template chooser" item called "event planner".
    So far, it's adapting nicely to our needs, BUT some items incur sales tax, others do not. Some items involve a gratuity, others do not.
    I understand the idea of adding an E column with the basic formula =D*7.25% or an F column with =D*20%
    but that would add tax to EVERYTHING - question is this
    If I add two columns of checkboxes, one for YES TAX, one for YES GRATUITY
    how would I write the formula to say "If E is checked, then multiply D by 7.25%; if F is checked, then multiply D by 20%; add these two numbers together and put them in column G; if neither box is checked, put the value of D into G"
    then I could SUM column G (???)
    Thanks in advance for any help!

    Buster,
    This formula will work (long form):
    =IF(AND(B2=TRUE,C2=TRUE),A20.0725A2+0.2*A2,IF(B2=TRUE,A2+0.0725*A2,IF(C2=TRUE,A20.2A2,A2)))
    and can be simplified to:
    =IF(AND(B2=TRUE,C2=TRUE),1.275A2,IF(B2=TRUE,1.0725*A2,IF(C2=TRUE,1.2A2,A2)))
    I would point out, however, that tax rates and tip amounts tend to change. So instead of putting constant values in the formula, you may wish to replace them with cell references to the tax and tip rate values. Then should these values change, you need to change them in only one place rather than all your formulas.
    pw

  • How can I get JavaScript for Windows 7 in order to connect to certain links?

    I have JavaScript 1.6.0_27 and a website is sending me information which I cannot get because their website only supports up to JavaScript 1.6.0_26. How can I install JavaScript 1.6.0_26 on my computer?

    Please continue at --> https://support.mozilla.com/en-US/questions/891126
    Moderator: Duplicate; please LOCK this thread - https://support.mozilla.com/en-US/questions/891123

  • How do I write code for a website that is viewed in different browsers?

    Hello.  My website looks fine when using the Firefox and Safari browsers.  But when I went to the library and viewed it using Internet Explorer, it looks bad.  It doesn't look the way I want it to.  Many of the elements are in different positions, etc.  I thought about how to correct this.  And I'm guessing that another html file can be created with another style sheet attached and designed just for Internet Explorer.  But then I thought about how the server would determine which file to use when the visitor types in the URL.  I have no idea how to do this.  I would greatly appreciate knowing how to write code that enables visitors, whether they use Firefox or Internet Explorer, to view my website that has the same style and elements in the correct positions on each webpage.   Thank you very much.

    You need to close your img tags (shown below in red).
    <img src="images/home_page/snowscene_web.jpg" />
    <img src="images/home_page/2011-1_201_p5_christians_nora_pixel2_2_web.jpg" />
    <img src="images/home_page/poster_final_web.jpg" />
    Your home page looks OK in IE8 & 9 but looks bad in Compatablity Mode (which is essentially IE7).  Try adding this META tag just below your <title> tags.  This will force older IE browser into IE8 or IE9 standards mode if it's available.  IE7 is pretty much obsolete now.
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    Nancy O.

  • Question - How to Revise a Javascript for Printing a Dynamic Date in the Right Corner of the Page

    Hi Everyone,
    I am using Adobe Professional 8.0.
    How do I revise the JavaScript (not created by me) below in order to execute the two (2) following changes:
    1) Dynamic Print Date - 1.0 inch Up and 1.0 inch Over from the Right Corner of the Page.
    2) Dynamic Print Date - 0.5 inch Up and 1.0 inch Over from the Right Corner of the Page.
    The JavaScript I want to revise is the following:
    /* Put script title here */
    // Add field to each page of form
    var inch = 72;
    for (var p = 0; p < this.numPages; p++) {
    // create rectangle quads for field
    var aRect = this.getPageBox( {nPage: p} );
    aRect[1] = 1.0*inch;
    aRect[3] = aRect[1] - 72; // and 24 points high
    // now construct text field to fill with date information
    var f = this.addField("PrintField", "text", p, aRect )
    f.delay = true;
    f.textSize = 10;
    f.textFont="Arial,Bold";
    f.textColor = color.black;
    f.alignment = "right";
    f.readonly = true;
    f.print = true;
    f.hidden = true;
    f.delay = false;
    var myWillPrintScript = 'var f = this.getField("PrintField"); \r'
    + 'f.hidden = false; \r'
    + 'var d = new Date(); \r'
    + 'var year = d.getYear()+1900; \r'
    + 'f.value = "Print Out Date:" + (d.getMonth()+1) + "/" + d.getDate() + "/" + year; \r';
    var myDidPrintScript = 'var f = this.getField("PrintField"); \r'
    + 'f.value = ""; \r'
    + 'f.hidden = true; \r';
    this.setAction("WillPrint", myWillPrintScript);
    this.setAction("DidPrint", myDidPrintScript);
    Thank you for your help!
    Tracy

    this.addWatermarkFromText({
    cText: util.printd("mmmm dd, yyyy", new Date()),
    nTextAlign: app.constants.align.right,
    nHorizAlign: app.constants.align.right,
    nVertAlign: app.constants.align.bottom,
    nHorizValue: -72, nVertValue: 72
    Will insert the current Monday/Day/Year as a text watermark at the bottom of every page of a document, 1 inch up and 1 inch in from the right corner.

  • SapScript: How to change write format for Unit Price

    Hi Experts,
    I have created a sapscript form in English and Japan language.
    In the Japan form, the unit price and quantity are being display as 123,456.78.
    but in English form, the unit price and quantity are being displayed as 123.456,78.
    I am also using a custom program for my logic but when the English form is used, when i write netwr field in a character field,
    it is defaulted as 123.456,78 even inside the program. How can I changed this to 123,456.78?
    My user data default for value display is 123,456.78.
    The print program for the form is a standard program used for PO (ME2*N) printing.
    Thanks in advance!

    Hi Breakpoint,
    My user data default for value display is 123,456.78 already but when using English form it is not display as such.
    Need help.

  • How Can I write Script for Indesign set left indent

    I really need two scripts for indesign set left indent:
    1. If the left indent is: 8, 16, 24, 32, 40, 48, 56mm... set the first -8mm; if the left indent is 0, set the left indent 8mm, first -8mm.
    2. Whatever the first indent is, set the first 8mm.
    Can someone help me?

    Hi, Trevor
    I use change by list as below:
    grep {leftIndent:48mm} {leftIndent:56mm}
    grep {leftIndent:40mm} {leftIndent:48mm}
    grep {leftIndent:32mm} {leftIndent:40mm}
    grep {leftIndent:24mm} {leftIndent:32mm}
    grep {leftIndent:16mm} {leftIndent:24mm}
    grep {leftIndent:8mm} {leftIndent:16mm}
    grep {firstLineIndent:8mm, leftIndent:48mm} {firstLineIndent:8mm, leftIndent:56mm}
    grep {firstLineIndent:8mm, leftIndent:32mm} {firstLineIndent:8mm, leftIndent:48mm}
    grep {firstLineIndent:8mm, leftIndent:24mm} {firstLineIndent:8mm, leftIndent:32mm}
    grep {firstLineIndent:8mm, leftIndent:16mm} {firstLineIndent:8mm, leftIndent:24mm}
    grep {firstLineIndent:8mm, leftIndent:8mm} {firstLineIndent:8mm, leftIndent:16mm}
    grep {firstLineIndent:-8mm, leftIndent:48mm} {firstLineIndent:-8mm, leftIndent:56mm}
    grep {firstLineIndent:-8mm, leftIndent:32mm} {firstLineIndent:-8mm, leftIndent:48mm}
    grep {firstLineIndent:-8mm, leftIndent:24mm} {firstLineIndent:-8mm, leftIndent:32mm}
    grep {firstLineIndent:-8mm, leftIndent:16mm} {firstLineIndent:-8mm, leftIndent:24mm}
    grep {firstLineIndent:-8mm, leftIndent:8mm} {firstLineIndent:-8mm, leftIndent:16mm}
    but not that perfect,
    I want to useing jave "if{}" or "for{}" to write this script, but I don't kown the syntext.

  • How to make write protect for Excel

    Hi all
    I need a clarification from you all
    I am exporting my data's to Excel sheet and saving it in the hard disk.
    I need to protect the sheet with password for opening the sheet
    Kindly can anyone help me in this
    Thanks
    Regards
    Bala

    Have a look at the image below to password protect your workbook:
    Make sure that you close all the references to Excel. Each refnum wire needs to end either in an indicator if it is going to be a sub VI, or an Automation close if the VI is not a subVI.
    Message Edited by JoeLabView on 06-24-2008 12:33 PM

  • How can i write code for close my application

    Hi,
    I m doing one apps in which i have 2 option and Agree and Quit. When user press Quit then my apps should be close and direct to main page of iphone. My apps should terminate.
    So anyone know that how can i do that?
    Thanks.

    Thank friend......... thanks a lot.... its working.......

  • How can I write javascript in UIX?

    code :
    <checkBox onClick="javascript:click()"/>
    <script>
    <contents>
    function click(){
    </contents>
    </script>
    it does not work . Can you help me?

    my code :
    <bc4j:table proxied="true"
    name="viewTableInvoice"
    alternateText="No data">
    <tableSelection>
    <singleSelection>
    </singleSelection>
    </tableSelection>
    <bc4j:keyStamp>
    <bc4j:rowKey name="key"/>
    </bc4j:keyStamp>
    <contents>
    <checkBox onClick="javascript:countInvoice()" />
    </contents>
    </bc4j:table>
    <script>
    <contents>
    <![CDATA[function countInvoice(){
    var proxy = new TableProxy('viewTableInvoice');
    var row = proxy.getSelectedRow();
    if (row < 0){
       alert('You have not chosen anyone!');
    }else{
    var name = proxy.getFormElement('Amount', row).value;
    alert('You have chosen to hire '+name);
    }}]]>
    </contents>
    </script>
    Why ,it does not work.

  • How can I write to a file from a livecycle designed PDF?

    I am producing a PDF in Livecycle designer and would like to write a sub-set of data from the document.
    I have tried methods such as exportData() but this exports everything which i don't need.
    I have seen another method which is to attach a file and write to that but ideally I'd just like to be able to create a new file.
    var data = xfa.data.nodes.item(0).nodes.item(1).saveXML()  var oFile = util.streamFromString(data , "utf-8");
    I would like to write oFile.
    Thanks in advance
    Edit:
    I would like to add that ideally the user would be presented with a save as dialog  box, so the can choose the location of where to save the xml data.

    an extraction out of expert one-on-one from Thomas Kyte
    <quote>
    when an oracle istance is created the services that support it are setup to 'log on as' the system (or operating system) account, this account has very few privileges and no acces to Window NT Domains. To access another Windows NT machine the OracleServiceXXXX must be setup to logon to the appropriate Windows NT Domain as a user who has acces to the required location for UTL_FILE.
    To change the default logon for the Oracle services go to (in Windows NT):
    Control Panel | Services | OracleServiceXXXX | startup | log on as; (where XXXX is the instance name)
    In Windows 2000, this would be:
    Control Panel | Administrative Tools | Services | OracleServiceXXX | Properties | Log on tab; (again XXXX is the instance name)
    Choose the This Account radio button, and then complete the appropriate domain login information. ONce the services have been setup as a user with the appropriate privileges, ther are two options dfor setting UTL_FILE_DIR:
    * Mapped Dirve: To use a mapped drive, the user that the service starts as must have setup a drive to match UTL_FILE_DIR and be logged onto the server when UTL_FILE is in use.
    * Universal Naming Convention: UNC is preferable to Mapped Drives because it does not require anyone to be logged on and utl_file_dir should be set to a name in the form \\<machine name>\<share name>\<path>
    You will of course need to stop and restart Oracle after changing the properties of the service.
    <\quote>
    I want to write some data to a (external) file. I have it working with the function UTL_FILE.
    My problem is I want to write to a file on a mapped drive (so a drive on a different machine). This is not working.
    Does anyone know a way to build this.
    Please send your responses to [email protected]
    Many thanks,
    Alex Nagtegaal

Maybe you are looking for

  • HP integrated bluetooth module in Pavilion dv7-2173cl Entertainm​ent Notebook PC support A2DP?

    Is my 2009 internal bluetooth module out of date?  Can I upgrade? I can connect an external bluetooth speaker, but windows is unable to find drivers.  According to HP.com, the drivers are up to date.  The icon for the speaker shows up in Devices and

  • No Dialog (audio) from Blue Ray Player

    I am running a Sharp BD-HP21U blue ray directly into a Mitsubishi LT-52149 HDTV with an HDMI cable.  On all blue ray discs and some DVDs I only hear the background music/sound effects but no dialog.  On some DVDs I get dialog.  Same result with a dif

  • HT201178 keyboard wont connect

    i had to change the batteries in my keyboard and in the time it took me to do that, my computer went to the screen saver and is password protected and now my keyboard wont connect... so im bassically locked out of my computer which is a mac mini.. wh

  • Installation of Oracle developer 10g with database 9i in single box

    I want to install Oracle developer 10g (Forms/Reports) with oracle database 9i. Can Forms/Reports 10g servers reside on the same box that holds the database 9i as well? Please provide me the solution for the same.

  • How to use Date data type ?

    Hi @, I have to use date type in my datatype but the format for the same is different and i dont know where to specify the same please help? Also how to define datetime type with format yyyy-mm-dd.Thh:mm:ss ? If there any place to specify the format