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

Help With Radio Button(s)

Participant ,
Oct 25, 2018 Oct 25, 2018

Copy link to clipboard

Copied

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

Views

617

Translate

Translate

Report

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();

Votes

Translate

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

Copy link to clipboard

Copied

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();

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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();

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

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