Skip to main content
Inspiring
August 16, 2021
Question

Working with Radio Buttons Individually

  • August 16, 2021
  • 2 replies
  • 1887 views

Hello everyone!

 

Is it possible to create individual Radio Buttons?

And in case there is one Radio Button only, can I attribute a string value to it, in the following manner,

ommitting the "Choice1" element in its description?

 

Example:

var they = this.getField("Group53").value 

 

If it is not acceptable, what would the best way to do that?

Thanks a lot for you reply in advance.

 

 

 

This topic has been closed for replies.

2 replies

Inspiring
August 20, 2021

var sentence = "They have got a new car.";


if((myRegExp.test(sentence)) && (myRegExp2.test(sentence))){

app.alert("It´s working!",2)
}
myRegExp = new RegExp(this.getField("Check Box1").exportValues);
myRegExp2 = new RegExp(this.getField("Check Box2").exportValues);

 

Thom Parker
Community Expert
Community Expert
August 17, 2021

Radio button are of course meant to be groupted together, since, they can only be clicked "On", and cannot be clicked "Off". 

But sure, you can use just one. A form reset will turn it off. 

I don't understand what you mean by "Choice1" in it's description. "Choice1" is the radio button's export value. And you can set the export value to anything you want. 

Read This:

https://www.pdfscripting.com/public/Checkboxes-and-Radio-Buttons.cfm

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Inspiring
August 17, 2021

Thanks for you reply.

 

Let me explain in more details what I´m planning to do.

Please observe this picture.

I want my student to click on each radio button and choose the options of words that form a meaningful sentence.

In this case, the sentence is: "They have got a new car." 

As you can see, there is an odd word (afternoon) which I expect my student to dismiss. But in case he doesn´t dismiss it, I need a dialog box to pop out and make him review his choice.

The challenge for me is how to make the individual radio buttons to comunicate in a way they recognize

that the words chosen form a meaningful sentence, regardless of the order the student chooses them, and in case my student chooses at any time, the unwanted word, that the alert dialog box pops out.

From your text I understand that perhaps it is better to work with checkboxes, instead of radio buttons.

In this case, is it possible to substitute the "YES" export value in the Option Tab for another word?

I wrote a script that accepts the student´s choice, in case he picks up the right words.

But how can I make my Javascript reject the student´s choice, in case he picks up the unwanted word?

 

Any advice on that will be much appreciated.

Cheers!

 

 

Nesa Nurani
Community Expert
Community Expert
August 17, 2021

Yes, you can replace "Yes"  in checkbox export value.

I didn't understand ,do you want alert to pop as soon as student select 'unwanted' checkbox?In that case don't include that checkbox in your script just add code into that checkbox "Mouse UP" event to pop alert if checkbox is checked:

if(event.target.value != "Off")
app.alert("Your message goes here",3);

Also if you want alert if sentence is not correct,you could use regexp to check text field for words and if field contain all words and text is not "They have got a new car." set alert.