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

Help With Radio Button(s)

Contributor ,
Oct 25, 2018 Oct 25, 2018

I am trying to understand how Radio Buttons Work.

For example. How do I show an alert box when one of the radio Buttons are selected.

var w = new Window ("dialog");

w.alignChildren = "left";

var radio1 = w.add ("radiobutton", undefined, "Option A");

radio1.value = true;

var radio2 = w.add ("radiobutton", undefined, "Option B");

w.show();

TOPICS
Actions and scripting
806
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

correct answers 1 Correct answer

Contributor , Oct 25, 2018 Oct 25, 2018

Do you mean like this? Using onClick function?

var w = new Window ("dialog");

w.alignChildren = "left";

var radio1 = w.add ("radiobutton", undefined, "Option A");

radio1.value = true;

var radio2 = w.add ("radiobutton", undefined, "Option B");

radio2.onClick = function (){

    alert ("hello world!")

    }

w.show();

Translate
Adobe
Contributor ,
Oct 25, 2018 Oct 25, 2018

Do you mean like this? Using onClick function?

var w = new Window ("dialog");

w.alignChildren = "left";

var radio1 = w.add ("radiobutton", undefined, "Option A");

radio1.value = true;

var radio2 = w.add ("radiobutton", undefined, "Option B");

radio2.onClick = function (){

    alert ("hello world!")

    }

w.show();

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
Contributor ,
Oct 25, 2018 Oct 25, 2018

Also, if you set the default value of radio1 to false, you can give that a function too.

You can still use onClick with radio1.value = true, but it means it will only occur when you click off and click back on.

var w = new Window ("dialog");

w.alignChildren = "left";

var radio1 = w.add ("radiobutton", undefined, "Option A");

radio1.value = false;

var radio2 = w.add ("radiobutton", undefined, "Option B");

radio2.onClick = function (){

    alert ("hello world!")

    }

radio1.onClick = function (){

    alert ("bye world")

    }

w.show();

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
Contributor ,
Oct 25, 2018 Oct 25, 2018
LATEST

Thank You. I never thought about the on click event, my mind was thinking on a change event for some reason.

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