Calculate a field if box is checked

Hi,
In one of the forms, I am trying to calculate a field value if a box is checked. For aesthetic reason, there are two checkbox field  (Yes/No) with the same field name "CT_Looped" but with different export value - Yes and No. Such that if someone checks Yes, they cant check no and vice versa.
I have the following code in the custom script for the field, which is part of a bigger code:
var DD4 = +getField("PT").value;
var DD3 = +getField("CT").value;
var KW1 = +getField("KWH 1").value;
if (this.getField (CT_Looped).value == "Yes") {  //if the field is checked with an export value Yes
                         event.value = (DD3 * DD4* KW1)/2;}
                else{
event.value = DD3 * DD4* KW1;}
What I am trying to do is if the CT_looped "Yes" checkbox is checked, then field calculates the value as DD3 * DD4* KW1)/2. If its not checked or if the "No" checkbox is checked, then it performs DD3 * DD4* KW1. If neither are checked, then default value of the field is just DD3 * DD4* KW1.
When I check/Uncheck the boxes, nothing happens. Can someone help?

Hi Michael,
thanks! that worked. I have one more question. It's part of a bigger code. each part works separately just fine but together it doesnt.
this is what I am trying to do:
if DD4>0, then if the CT_Looped box is checked, then it should perform  (DD3 * DD4* KW1)/2 otherwise perform DD3 * DD4* KW1.
so for example, DD1 =1, DD3 =100,DD4 =2, KW1 = 1, qty = 1, Auto = drop down with (0, .5,2, 4)
then if i check the box, the value should be 100, otherwise 200, but with the code i created below, if i check the box, the field is always 200 instead of 100. Rest everything works. If i change the Auto ratio from 0 to 2, it becomes 400 as expected. If DD4<0, then if i change qty, the change is reflected as expected. I just cant seem to get the right order of code in which the logic should work correctly.
Any advice? tips?
code is below:
var DD1 = +getField("Factor").value;
var DD4 = +getField("PT").value;
var DD3 = +getField("PT_2").value;
var KW1 = +getField("KWH 1").value;
var qty = +getField("qty").value;
var Auto = +getField("Auto").value;
if (DD4>0){
if (this.getField ("CT_Looped").value == "Yes") { 
event.value = (DD3 * DD4* KW1)/2;}
                                                else {
event.value = DD3 * DD4* KW1;}
if (Auto>0){
event.value = DD3 * DD4* KW1* Auto;}
                                                else{
event.value = DD3 * DD4* KW1;}
else if( ctqty > 1){
event.value = DD3 * DD1* KW1 ; }
else{
event.value = DD3 * KW1;

Similar Messages

  • I/O field grayed out after check box checked ( Dynpro)

    Hi ,
    I have dynpro  dialog screen  with several check boxes linked with input/output field
    When check box is checked the I/O field is editable when check box is empty I/O field should be grayed out.
    I am trying to find the way how checking the check box can trigger the change of attribute of I/O field.
    The IO field should be gray out after checking check box without hitting enter or any other button.
    Please advice
    Chris

    Hi ,
    Thank you for your answer. I was missing Functional code of my check boxes.
    Now i have still issue my I/O field do not turns in gray ( only output) In loop
    I dide like you said ( this is example from my PAI module user-command)
    when 'CB1'.
          loop at screen .
            if screen-name = 'LT_FORMAT_IO'
              and lt_format_cb is initial.
              screen-input = '0'.
              screen-invisible = '1'.
              modify screen.
            endif.
          endloop..
    Once screen is displayed again , the IO field stll remains non grayed out.
    Please advice
    Chris

  • How to make text box required field if checkbox is checked??

    I have a web form that I need to look something like this:
    (Checkbox) Check here if it is for an individual  ID: (textbox) Required field if checkbox is checked and a numeric value
    (Checkbox) Check here if it is for an organization ID: (textbox) Required field if checkbox is checked and a numeric value
    (Checkbox) Check here if is neither (textbox is hidden and not required if "neither" is checked)
    Currently the form looks like this: http://ncsu.edu/advancement-services/resources/researchrequest.html.  The above information is going to go where it says prospect name and id number on the form.  I would like to have the three checkboxes in a menu instead if that is possible.
    How do I make the form do this?  I created the form in the above link but I don't can't figure this one out.
    Thanks so much in advance!!
    Erika Roe

    Sharmila,
    My form is based on Master/Detail Table....I have chosen defalt layout ...Not a Custom form.
    In this case,could you suggest me what I should do ?..The customer is very much insisting on that..
    Thanks in Anticipation
    Babu

  • How do you calculate multiple fields in a Form?

    Hi,
    I have a spreadsheet with several headings and several fields as illustrated below, and description of each field and calculation required is listed below.
    Rate Per Day
    Days
    Course
    Attending
    Total
    $1,000
    2
    Course A
    Yes
    $2,000
    $2,000
    1
    Course B
    Yes
    $2,000
    $5,000
    5
    Course C
    No
    $2,000
    2
    Course D
    Yes
    $4,000
    Total:
    $8,000
    Rate per day:  Field value is inputted by us.
    Days:  Field value is inputted by us.
    Course:  Field value is inputted by us.
    Attending:  Is actually a check-box that the client ticks.
    Course Total:  This should be the calculation of RATE PER DAY * DAYS IF ATTENDING BOX IS CHECKED
    Total:  Sum of above COURSE TOTAL FIELDS
    We currently do this in EXCEL 2007, however we looking at converting it to a PDF Form for distribution to our clients to we can track responses, etc.
    My question is really ery simple ... how do I create the above calculations in a form that I want to distribute??  This possible?? If so how (please bear in mind I'm not a developer

    In re-reading your question, I realized you're using a check box. In that case, you will need to create a custom calculation script using JavaScript.
    Something like:
    // This is a custom calculation script
    (function () {
        // Get the value of the check box
        var v1 = getField("Attending1").value;
        if (v1 !== "Off") {
            var v2 = +getField("Rate1").value;
            var v3 = +getField("Days1").value;
            // Sum the two field values and set the value of this field to the result
            event.value = v2 + v3;
        } else {
            // Blank field if checkbox is unchecked
            event.value = "";
    You'd replace the field names I used with the field names you're using.
    This leaves out checking to see if the corresponding Couse field is filled-in, and you'll have to use a custom Format script if you want the type of formatting you show.

  • Creating List box and check box in structure

    Hi
    I have to include List box(Drop down) of lenght 20 and check box in a screen area.
    The fields on screen are to be transported from structure CI_PROJ in table PROJ.
    How can i Include List box and check box in my structure CI_PROJ.
    Also wat data type is required

    Hi,
             For the list box if you have the data element along with the search help then you can use that dataelement. If you dont have search help at dataelement level then for the structure you have to assign a search help directly. If you dont have data element it self then domain's fixed values will be shown in the drop down. For the check box you have to use a data element with a domain having CHAR and length 1.
    For the list box you will KEY and VALUES. Key is the one that is transfered to your program data and VALUE is the one that is shown to the user. You have to use the data element of your KEY for the list box.
    Regards,
    Sesh

  • Send email only first time check box is checked?

    I am trying to set up an article insert form with a checkbox for requesting a photographer. I have it set up to send a photographer request email when the form is submitted and the checkbox is checked. The only problem is that on the update transactions it detects the checkbox checked and sends the email AGAIN. I can't delete the trigger from the update form since it may be checked for the first time there. What I am really looking for is a way to only send the email only the FIRST time a box is checked. Is there a way I might be able to get this to work? Or an easy workaround? Hopefully I am explaining this well. Any help or ideas would be appreciated. Thanks,
    -Dan

    Hi Dan,
    well, the only workaround I can think of would be adding this checkbox
    (assumingly submitting a Y/N value) to the insert/update transaction, means, to save the checkbox value in an extra (char 1) field named e.g. "email_sent" -- on your update page you can retrieve the current field value from the query and use this "status" as "condition" for sending an email, means, if the field´s value currently equals N, the email will be sent, otherwise not.
    would that make sense ?
    Günter Schenk
    Adobe Community Expert, Dreamweaver

  • My autofill stopped working recently.  I looked under preferences and all the necessary boxes are checked.  When I start to fill out a form, the autofill box comes up, but when I click on it, it turns blue and nothing else happens.

    my autofill stopped working recently.  I looked under preferences and all the necessary boxes are checked.  When I start to fill out a form, the autofill box comes up, but when I click on it, it turns blue and nothing else happens.

    Back up all data, then test after each of the following steps that you haven't already tried. Stop when the problem is resolved.
    1. Press the down-arrow key. (Credit to ASC member iNeight.)
    2. Quit and relaunch Safari. Force quit if necessary.
    3. Click in the first field to be filled, and then select
    Edit ▹ AutoFill Form
    from the menu bar. You may have to reload the page in order to do this.
    4.  Select
    Contacts ▹ Preferences ▹ vCard
    and uncheck the box marked
    Enable private me card
    if it's checked.
    5. Select your card in Contacts. Then select
    Card ▹ Make This My Card
    from the menu bar.
    6. In Safari, select
    Safari ▹ Preferences ▹ AutoFill ▹ AutoFill web forms: Using info from my Contacts card
    If the box was already checked, uncheck it and then check it again.
    7. Launch the Keychain Access application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Keychain Access in the icon grid.
    Select the login keychain from the list on the left side of the Keychain Access window. If your default keychain has a different name, select that.
    If the lock icon in the top left corner of the window shows that the keychain is locked, click to unlock it. You'll be prompted for the keychain password, which is the same as your login password, unless you've changed it.
    Right-click or control-click the login entry in the list. From the menu that pops up, select Change Settings for Keychain "login". In the sheet that opens, uncheck both boxes, if not already unchecked.
    From the menu bar, select
    Keychain Access ▹ Preferences ▹ First Aid
    If the box marked Keep login keychain unlocked is not checked, check it.
    Select
    Keychain Access ▹ Keychain First Aid
    from the menu bar and repair the keychain. Quit Keychain Access.
    8. Run Software Update and install any available updates.

  • How do you send an email to a specific person based on if a particular check box is checked?

    How do you send an email to a specific person based on if a particular check box is checked?

    Try the LiveCycle Designer forum.

  • I have uninstalled and installed the latest Flash Player 17 many times.  I am currently working on a yearbook site that gets locked every time I try to add photos.  I have also received a plug in error even though the plug in box is checked.  I have a Mac

    I have uninstalled and installed the latest Flash Player 17 many times.  I am currently working on a yearbook site that gets locked every time I try to add photos.  I have also received a plug in error even though the plug in box is checked.  I have a MacBook Pro.  Please help!!!

    To give you any useful advice, I'm going to need to know more about your computer and browser:
    https://forums.adobe.com/message/5249945#5249945

  • How to validate that only one check box is checked in detail block

    Hi All,
    I am using oracle Forms 10G on windows.
    I need help on how to validate that only one check box is checked in detail block. I have multiple records in the detail block and I have check boxes for each record in the detail block.
    I have a button to select the values from the detail records where the check box is checked. But I want to make sure that only one record is check not more than one.
    How do I validate this on a push button trigger?
    Thanks

    When I've done this kind of thing, I create a Form level variable of TYPE number and then add or subtract to this variable as I check and uncheck the checkboxes. If the value of the variable is 1, then you know that only one checkbox is selected. If the value is greater than 1, then you know the user has selected more than one check box. You could also add code to your When-Checkbox-Changed trigger to test the variable and instruct the user to un-check selected record before selecing a new record.
    With respect to the Form level variable, you can use a GLOBAL, PARAMETER or Program Unit package specification. I prefer to use the PU Package Spec as this method has a smaller memory footprint. For example, in the Program Unit node of the object navigator create the following;
    /* Form variables package spec */
    PACKAGE Form_Vars IS
      CheckBox_Cnt     NUMBER := 0;
    END;Now in your When-Checkbox-Changed trigger...
    BEGIN
       IF ( Form_Vars.CheckBox_Cnt = 0 ) THEN
          Form_Vars.CheckBox_Cnt  := Form_Vars.CheckBox_Cnt  + 1;
       ELSE
          /* it's assumed the value is greater than 0 */
          Message('Please uncheck selec ted record before choosing a new record.');
          RAISE Form_Trigger_Failure;
       END IF;
    END;Hope this helps,
    Craig B-)
    If someone's response is helpful or correct, please mark it accordingly.
    Edited by: CraigB on Feb 3, 2011 10:15 AM

  • How to calculate KBETR field in SD pricing

    Hi Experts,
    I have one Alterante calculation routine to calculate KWERT field in SD pricing
    FORM FRM_KONDI_WERT_700.
    *{ INSERT LEDK900048 1
    if xworkd ne 0.
    xkwert = xworkd - komp-wavwr .
    endif.
    *} INSERT
    ENDFORM.
    My problem is, that after this calculation, I need to change KBETR field in the same condition as percetage: calculated value / net price.
    But KBETR field cannot be changed in the routine above. Is there any other choice how to do it?
    Thanks&regards,
    Jirka Faltin

    its a  perfect code.
    refer this
    IT_KONV-kbetr = abs( IT_KONV-kbetr ).
          if IT_KONV-kbetr > 0.
            IT_KONV-kbetr = ( IT_KONV-kbetr / 10 ).
          ENDIF.
          IT_REPORT-LV_SHARE2 = IT_KONV-KBETR .
    u will get kbetr in percentage.

  • Firefox is suddenly not remembering or filling in any of my passwords. All of the appropriate boxes are checked in the options/security tab, but it won't remember any passwords and shows none saved. How do I get it to remember and fill in my passwords a

    Firefox is suddenly not remembering or filling in any of my passwords. All of the appropriate boxes are checked in the options/security tab, but it won't remember any passwords and shows none saved. How do I get it to remember and fill in my passwords again?

    Do you mean names and passwords in the Password Manager or do you mean that you are no longer logged on to (remembered by) websites after closing and restarting Firefox?
    If the latter happens then you have a problem with cookies that are not kept or the file that stores the cookies is corrupted.
    Websites remembering you and automatically log you in is stored in a cookie that you must allow: Tools > Options > Privacy > Cookies: "Exceptions"
    Make sure that you do not use [[Clear Recent History]] to clear the 'Cookies' and the 'Site Preferences'.
    Make sure that you not run Firefox in [[Private Browsing]] mode.
    In Private Browsing mode some menu items are disabled (grayed) and some features like visited links and others are disabled and not working.
    You are in Private Browsing mode if you see "Tools > Stop Private Browsing".
    See [[Private Browsing]] and http://kb.mozillazine.org/Issues_related_to_Private_Browsing
    See also http://kb.mozillazine.org/Password_Manager (Troubleshooting)

  • How to create value request for screen field text box tt1

    How to create value request for screen field text box tt1
    i have a text box name tt1,
    i want f4 help for that .
    remember i am asking for screen i.e done from screen layout not selectio-screen.
    Thank you,
    Regards,
    Jagrut Bharatkumar Shukla,

    Hi,
    Create one Search Help in the SE11 for the particular Field that u want to display. In the Screen(Transaction SE51),For that Text Box in the Attributes,in Dict Tab ->Search Help Field give that Search Help Name.
    For Eg,
    If u want Purchase Order Numbers in that F4 Help.Create one <b>Search Help</b> by giving Table Name as <b>EKKO</b> & <b>Search Help Parameter</b> as <b>EBELN</b> with Lpos & Rpos as 0 & 1.Save & Activate it.
    Give this Search Help Name in Dict Tab ->Search Help Field of that Screen Attributes.
    Regards,
    Padmam.

  • Entry in field Funds Center required; check the field control Mg No.FMEF010

    Hi,
    We have a Z tcode for converting planned order to purchase requisition.
    We use Account assignment P - Project and A - Asset.
    We have WBS element and fund center linked to it.
    For the Z tcode while converting Planned order to purchase requisition we are getting below error
    Error: Entry in field Funds Center required; check the field control Msg No.FMEF010
    While creating manually purchase requisition with same GL code and WBS element the fund center gets automatically picked.
    Can anyone pls let me know in which table we can find the link between WBS element and fund center so that we can code the same in our program. In PRPS table we can find the link between WBS and profit center.
    Or is there any user exit that can be used.
    Thanks in advance.
    Regards,
    Radha

    Hello
    If you do a F1 in the value date field it will give you the answer - The value date is used in bank accounts and bank sub-accounts.
    As regards the other query check whether the tax code has been already created.
    Hope it helps.
    Rgds

  • Calculate price field in SRM-MDM

    Hi.
    I am using the standard SRM-MDM repository as my catalog. We recieve products and price information from different suppliers. But from one supplier we also receive a "discount" file. This file contains product number and a discount percentage. How can I calculate the new product price? The price field is from SAP set to currency type and is multivalued. It is also a part of the qualified lookup table price. And as far as I know it is not possible to add an assignment that calculates a field in a qualified table, and the fact that it is multivalued makes it impossible as far as I can see it.
    Does anyone have any ideas? I have tried to solve this in the import map with value conversation, but the calculation opportunity here only supports fixed numbers.
    Example:
    Price amount: 50 EUR, stored in SRM-MDM
    Discount in file 50 %.
    Wanted new value in price field: 25 EUR
    Regards, Anders

    Hi Anders,
    I found the solution for this in your subject(Calculated field), I think the possible solution can be:
    Amount as Currency.
    Price can be set as Currency and Calculated as Yes.
    Discount as an integer.
    In calculation expression write the expression, where if discount is Null the Price = Amount else calculate the discount and assign it to the price.
    I hope this might work out and be useful to you. Let me know the results.
    Regards,
    Cherry.

Maybe you are looking for

  • MacBook Pro 17" Mid 2010 wifi "no hardware installed" fix

    Hello, Wanted to share my "wifi: no hardware installed" fix for my 17" mbp. Story is short - some time ago I noticed that sometimes after sleep there is no wifi. I'm carrying my laptop with me every day in backpack, so it just won't connect to any kn

  • MSI Mega Sky Aerial

    Hi just wondering if anyone knows if the MSI Mega Sky Aerial is weather proof..... please reply.

  • [solved] ntp sync for more than 24 hours

    What I am trying to do: I discovered that my server was out by about 8 minutes the other day. I have run ntpd -qg but I'd like a solution to stop this happening in the future. I've read: https://wiki.archlinux.org/index.php/Time https://wiki.archlinu

  • Help Cannot Download Itunes -

    it brings up a message " The Installer encountered errors before itunes could be configured  - Errors occurred during installation - your system has not been modified  - Anyone any ideas?? Thanks

  • Opening a a .lnk file to a word .dot file

    ''Duplicate post, continue here - [https://support.mozilla.com/en-US/questions/786768]'' Hi I am trying to open a .lnk file to word template file that contains macros, when i select the open with word for this file type firefox will open the link fil