Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Radio Button selection pulling data from one field to another?

Community Beginner ,
Dec 19, 2018 Dec 19, 2018

Hi there,

Big thanks to everyone, I already received great help on this forum from technical wizards!

User inputs manually into RentPW (rent per week) i.e, 500, 550, 1000 etc

There is a radio button PaymentType with TWO either-or choices:

Full - Pay everything up front in full

Part - Pay monthly

If the user selects Choice 1, I need the SecureDep field to be populate with: RentPW * 2

If the user selects Choice 2 - I need the SecureDep field to be populated with: RentPW * 6

Is this possible?

Just in case, I have attached the actual form: Dropbox - Test Booking Form.pdf

TOPICS
Acrobat SDK and JavaScript
762
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 19, 2018 Dec 19, 2018

I have tried the following but it didn't work 😕

var a = this.getField("PaymentType").valueAsString; 
var b = this.getField("Part").valueAsString; 
var c = this.getField("Full").valueAsString;
var RentPW = +getField("RentPW").value;

if (a=="Part") event.value = RentPW * 6; 
else if (a=="Full") event.value = RentPw * 2; 
else event.value = ""; 
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 19, 2018 Dec 19, 2018

Are there fields called "Part" and "Full"? If so, what do they have to do with this calculation?

And yes, it's certainly possible to do it.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 19, 2018 Dec 19, 2018

There aren't any fields, Full and Part are just the options or choices that are given to the user.

The radio button group is called PaymentType and the first box checked is called Full and the second box is called Part.

Hope I'm explaining it clearly. I don't understand why my script doesn't work?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 19, 2018 Dec 19, 2018

Because you're trying to access non-existing fields... Remove those two lines and it should work.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 19, 2018 Dec 19, 2018

Thanks Try,

I used this and it works:

var SecureDep = +getField("SecureDep").value;

    var RentPW = +getField("RentPW").value;

    var RentPCM = +getField("RentPCM").value;

    var ContractLength = +getField("ContractLength").value;

var PaymentType = this.getField("PaymentType").value;

if (PaymentType=="Full") {

    event.value =  2 * RentPW;

} else event.value = 6 * RentPW;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 19, 2018 Dec 19, 2018
LATEST

Why do you continue to define variables that are not used in the actual code later on?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines