Quitter
  • Communauté internationale
    • Langue:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티

Help With Radio Button(s)

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

SUJETS
Actions et scripting
807
Traduire
Signaler
Directives de la communauté
Restez bienveillant et courtois, ne vous attribuez pas la paternité des créations d’autrui et assurez-vous de l’absence de doublons avant de poster du contenu. En savoir plus
community guidelines

correct answers 1 bonne réponse

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

Traduire
Adobe
Contributeur ,
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();

Traduire
Signaler
Directives de la communauté
Restez bienveillant et courtois, ne vous attribuez pas la paternité des créations d’autrui et assurez-vous de l’absence de doublons avant de poster du contenu. En savoir plus
community guidelines
Contributeur ,
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();

Traduire
Signaler
Directives de la communauté
Restez bienveillant et courtois, ne vous attribuez pas la paternité des créations d’autrui et assurez-vous de l’absence de doublons avant de poster du contenu. En savoir plus
community guidelines
Contributeur ,
Oct 25, 2018 Oct 25, 2018
LA PLUS RÉCENTE

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

Traduire
Signaler
Directives de la communauté
Restez bienveillant et courtois, ne vous attribuez pas la paternité des créations d’autrui et assurez-vous de l’absence de doublons avant de poster du contenu. En savoir plus
community guidelines