Skip to main content
Yellow Duckie
Participating Frequently
April 12, 2018
Answered

How do I make several radio buttons show a single text field?

  • April 12, 2018
  • 1 reply
  • 1178 views

Good afternoon everyone.

At the start of every form we fill out, we usually have to write in our personal information such as name, address, phone number, etc.  I have something similar to that, but I want to give the user a chance to save what they have in a separate file before continuing.  In theory, what I'm doing is giving the user a chance to save the file to a new location so they don't accidentally overwrite their copy, and once they've entered all the pertinent information, a button will be revealed that when clicked executes a Menu Item of File>Save As .  Make sense?

Once the user fills all of these fields in, another text field labeled "Submit" will appear.  I'm using a text field because I'm using the Custom Calculation Script:

var bReady = true;

if(this.getField("DateOfReview").value.length == 0)   bReady = false;

else if(this.getField("ArrivalTime").value.length == 0)   bReady = false;

else if(this.getField("DepartureTime").value.length == 0)   bReady = false;

else if(this.getField("DateOfLastReview").value.length == 0)   bReady = false;

else if(this.getField("MonitorName").value.length == 0)   bReady = false;

else if(this.getField("MonitorTitle").value.length == 0)   bReady = false;

else if(this.getField("SiteName").value.length == 0)   bReady = false;

else if(this.getField("SiteID").value.length == 0)   bReady = false;

else if(this.getField("SiteAddress").value.length == 0)   bReady = false;

else if(this.getField("SiteRep").value.length == 0)   bReady = false;

else if(this.getField("SiteRepTitle").value.length == 0)   bReady = false;

if(bReady)   this.getField("Submit").display = display.visible;

else   this.getField("Submit").display = display.hidden;

The label "Submit" will later be changed; it was what I could think of at 2am...

I just don't know how to insert a radio group after Arrival Time and Departure Time.  Each field of "Time" has a radio button for "AM" or "PM".  We can't get rid of it; it's required to have separate radio buttons in this form, which is okay because then we can use the Arbitrary Mask 99:99 for each time field.

So how do I write in the line for the radio groups after each time?  It doesn't matter if AM or PM is selected, so long as one is.

I already know how to do a show/hide Action Script for revealing and hiding text boxes, but I can't seem to get that theory to apply with the rest of this. Is it possible?

Any help is appreciated.  Thanks!

This topic has been closed for replies.
Correct answer Thom Parker

I already answered the question. When no buttons in a radio button group are selected, the value of the group is "Off". So the if statement  needs to compare the value of radio button field to "Off".

A text field is a bad choice for a submit button. There is literally no reason why you can't use a button.

1 reply

Thom Parker
Community Expert
Community Expert
April 12, 2018

You really need to learn how to write more compact questions. There is way too much unrelated info here and it is difficult to parse. We don't have all day to answer questions for free.

So, I think the question you want answered is "How do you validate a Radio Button Group has a selected value". Even that was wordy.

The answer is simple, the value of an "unselected" radio button group is "Off".

On an unrelated note, is the calculation script you posted in the "Submit" field?  If so then the reference back to the Submit field is inefficient. Use "event.target".  There is also no reason to show the Submit Text field, why not use a Submit button. You're calculation script for validating the form can happily reside in a hidden text field, hiding or showing the submit button.

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Yellow Duckie
Participating Frequently
April 12, 2018

I'm sorry. I figured to give as much detail for my question as possible so I don't lose people.  I don't often realize I still lose people by giving the detail.

The Submit button is actually a hidden text field.  The code I provided is in the Calculations.  When information is provided the subsequent fields, the Submit field button appears.

My question is: How do I also include radio button groups to the else if(this.getField code?  I've tried several different codes, and none of them can do what I want.  Is it even possible?  I feel as if there is a way, but nothing I've tried has worked.

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
April 12, 2018

I already answered the question. When no buttons in a radio button group are selected, the value of the group is "Off". So the if statement  needs to compare the value of radio button field to "Off".

A text field is a bad choice for a submit button. There is literally no reason why you can't use a button.

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often