Copy link to clipboard
Copied
Hi there!
I have a registration form when the user must select one of three check box options, each checkbox has a different export value. I also have one dropdown list with "yes" or "no" as options, "yes" needs to equal 0 and "no" needs to equal $45.00.
I have a text field where I want to calculate the checkbox option and add any "no"selection to it.
I'm at a total loss and any help would be grealy appreciated.
Thanks!
Apologies for having not updated the thread sooner.
Yes, NessaNurani's solution worked beautifully! She was so gracious to further assist me via private message to better understand and learn how to replicate her solution myself, as I was having difficulty doing so. She was able to help me identify where I was going wrong.
A huge thanks to NessaNurani!
Cheers!
Copy link to clipboard
Copied
What exactly is the role of the checkboxes? You said you have three...what are the export values of each?
And what you're saying is, that when a user selects NO from the dropdown menu the texfield should take this string value plus the export value of whatever checkbox is checked?
Copy link to clipboard
Copied
Try this:
var a = this.getField("checkbox1").value;
var b = this.getField("checkbox2").value;
var c = this.getField("checkbox3").value;
var x = this.getField("dropdown1").value;
if(a!="Off"){
event.value = a+x;}
else if(b!="Off"){
event.value = b+x;}
else if(c!="Off"){
event.value = c+x;}
else event.value = 0;
don't forget to add export values to yes and no in dropdown field.
Copy link to clipboard
Copied
Hi there, I uploaded the example I'm working with if that's helpful:)
Copy link to clipboard
Copied
Hi there, that's exactly right!
Checkbox 1 = $150.00
Checkbox 2 = $180
Checkbox 3 - $150
Dropdown List "Yes" = $0.00
Droption List "No" = $45.00
Copy link to clipboard
Copied
Where do I copy and paste this script? Is it in the Text Field Properties of the fields I want to calculate the total amount under the "Calculate" tab - "Simplefied field notation"?
Thanks so mych for your help:)
Copy link to clipboard
Copied
I update your file to make the code work let me know if you need anything else.
Copy link to clipboard
Copied
Thank you so mych NesaNurani!!!
I tried to replicate what you did and don't know what I'm doing wrong:(
Last time promise bothring you I promoise...but could you take a look at this copy (CanSkate Skating Session - Updated Aug 29, 2020) and help me learn what I'm missing to get the field to calculate.
A huge thank you!:)
Copy link to clipboard
Copied
Hey Jennifer,
Would you mind updating this thread.
Did the solution provided by NessaNurani resolved your issue?
Thank you.
Copy link to clipboard
Copied
Apologies for having not updated the thread sooner.
Yes, NessaNurani's solution worked beautifully! She was so gracious to further assist me via private message to better understand and learn how to replicate her solution myself, as I was having difficulty doing so. She was able to help me identify where I was going wrong.
A huge thanks to NessaNurani!
Cheers!
Copy link to clipboard
Copied
You can use something like this:
if (this.getField("myDropdown").valueAsString !="Off") {
if (this.getField("myDropDown").valueAsString =="yes") event.value = util.printf("$%.2f", this.getField("myCheckBox").value);
else if (this.getField("myDropDown").valueAsString =="no") {
var a = this.getField("myCheckBox").value+45.00;
event.value = util.printf("$%.2f", a);
}
}
if (this.getField("myCheckBox").value ="Off") event.value = "";
Place this script as the custom calculation script of the text field where you want these results to be output.
See slide: