Skip to main content
Participant
February 1, 2022
Question

Simple radio button & check box textbox changes on selection

  • February 1, 2022
  • 1 reply
  • 1121 views

Hello all,

I am new to javascripting and I am working on a simple form that I am trying to program some simple logic into, to no avail can I find the correct syntax / formatting, anyplace and all the basic java scripting books I found listed on amazon have bad reviews and good reviews, but mostly bad.  So after sufing through this forum and not finding the information, I decided to make a post, thank you in advance for your input.

 

I belong to a small club and the logic I am trying to create is as follows, I am hoping someone can point me in the right directon.

I have 2 membership options Adult & Jr, I have assigned them each a grouped radio button and a read only text field.  Default is the adult radio button selected and matching text field populated with$15.00, the Jr text field is populated with $0.00.  

When you select the jr radio button I want the Adult field to go to $0.00 and the Jr text field to go to $3.00.

Then the revese if the adult radio button is selected, the adult text field populates $15.00 and the jr text field goes back to $0.00.

 

Then I have a single check box that says Key and the matching read only text box (keybox) and check box is defaulted unchecked and the textbox is defaulted $0.00, when checked the textbox populates $5.00 in the textbox and when unchecked reverts back to $0.00.

 

I then have a forth read only text box that autocalulates the totals of each textbox.

 

Basic layout of the form below.

 

UT’s Fishing Club Membership

  • Adult Membership 2022       $________
  • Junior Membership 2022      $________
  • Club Gate Key                      $________

                 Membership Due           $________

 

Thank you in advance for your help.

This topic has been closed for replies.

1 reply

BarlaeDC
Community Expert
Community Expert
February 1, 2022

HI,

 

In the action tab mouse up of the Radio button you can add the code that alters the contents of the fields.

 

if ( event.target.value == "Adult"){
    this.getField("AdultDollarField").value = "15.00";
    this.getField("JuniorDollarField").value = "0.00";
} else {
    this.getField("AdultDollarField").value = "0.00";
    this.getField("JuniorDollarField").value = "5.00";
}

 

Then in the validation tab of the checkbox you can add something similar, although you would need to change the fieldnames and values to match, and finally in the calculate tab of the membership due field you can add

 

event.value = this.getField("AdultDollarField").value + this.getField("JuniorDollarField") + this.getField("GateFeeField").value;

 

 

That should at least give you a start.

 

*edited to correct*

try67
Community Expert
Community Expert
February 1, 2022

Radio-buttons don't have a Validation tab... Maybe you meant the Actions tab, under Mouse Up?
If so, then it needs to be event.target.value, not event.value ...