Skip to main content
Participating Frequently
August 5, 2024
Question

Using check box in formula

  • August 5, 2024
  • 3 replies
  • 1273 views

Hello,

 

I need help creating a Java script when using checkbox

 

for example

when "CB1" is checked I need "LST" to  = $600

when "CB2" is checked I need "LST" to = $750

when "CB3" is checked I need "LST" to = $800

when "CB4" is checked I need "LST" to = $900

when "CB5" is checked I need "LST" to = $1100


Thanks

 

 

    This topic has been closed for replies.

    3 replies

    try67
    Community Expert
    Community Expert
    August 5, 2024

    If you only want one value to be selectable out of the group then give all fields the same name (for example, "CB"), but unique export values (the value should be just a number, without the dollar symbol).

    Then you could use a simple script for populating the selected value into a text field:

     

    var cb = this.getField("CB").valueAsString;

    if (cb!="Off") event.value = cb;

    else event.value = "";

    Participating Frequently
    August 7, 2024

    Thank you!

    Nesa Nurani
    Community Expert
    Community Expert
    August 5, 2024

    What should happen if multiple checkboxes are checked, do you want to sum the result in that case?

    If you don't want to sum the result, which checkbox should take precedence?

    Participating Frequently
    August 5, 2024

    Good question....

    this is for an order form and in theory only 1 box would need to be checked as the quanity/price gradually increases in each checked box option.

    Nesa Nurani
    Community Expert
    Community Expert
    August 6, 2024

    You can use this in a text field where you want to show price as 'Custom calculation script':

    var price = [600, 750, 800, 900, 1100];
    
    for(var i=1; i<=5; i++){
    var cb = this.getField("CB"+i).valueAsString;
    if(cb !== "Off"){
     event.value = price[i-1];
     break;}
    else
     event.value = "";}

    Although this should work for you, if only one checkbox should be checked at a time, consider using solution posted by try67.

    kglad
    Community Expert
    Community Expert
    August 5, 2024

    in the future, to find the best place to post your message, use the list here, https://community.adobe.com/

    p.s. i don't think the adobe website, and forums in particular, are easy to navigate, so don't spend a lot of time searching that forum list. do your best and we'll move the post (like this one has already been moved) if it helps you get responses.



    <"moved from using the community">