Copy link to clipboard
Copied
For a simple drop-down menu in javascript, what function do I need to add to make another parameter change when a user selects a specific menu option? Does onClick work? Like let's say I wanted to make a new layer appear when I picked option 2.
var newPanel = new Window("dialog","name",undefined);
var dropList = newPanel.add("dropdownlist",undefined,["Opt1","Opt2","Opt3"]);
dropList.selection = 0;
if (newPanel != null && newPanel instanceof Window){
newPanel.center();
newPanel.show();
}
Copy link to clipboard
Copied
Not my prefered solution...
#target photoshop
var newPanel = new Window("dialog","name",undefined);
var dropList = newPanel.add("dropdownlist",undefined,["Opt1","Opt2","Opt3"]);
dropList.onChange = function(){
newPanel.close()
switch(parseInt(dropList.selection)){
case 0:
//place your code here
alert("Opt1");
break;
case 1:
//place your code here
alert("Opt2");
break;
case 2:
//place your code here
alert("Opt3");
break;
}
}
if (newPanel != null && newPanel instanceof Window){
newPanel.center();
newPanel.show();
};
Copy link to clipboard
Copied
You really need onChange? Shouldn't there be a modifier function specific to dropdowns like onSwitch or something like that? Also why do you need alerts? Why would buttons have onClick but dropdowns have nothing?
Copy link to clipboard
Copied
What prevents you from reading the official documentation in which all this is written?
https://www.adobe.com/content/dam/acom/en/devnet/Images/JavaScript-Tools-Guide-CC.pdf
Copy link to clipboard
Copied
How about the fact that there's several different subtly labeled "official" documentations with drastically different information and that they are all badly written and difficult to find anything in?
Copy link to clipboard
Copied
[quote]Also why do you need alerts?[/quote]
They are not necessary. They only confirm visually whether "onchange" works.
Replace them with your own code...
Copy link to clipboard
Copied
Something else doesn't quite make sense. If all you need is onChange, why is there also this "switch" function in the proposed script?
Copy link to clipboard
Copied
d0 b4 d0 b5 d0 b1 d0 b8 d0 bb d1 8b 2c 20 d0 b1 d0 bb d1 8f d0 b4 d1 8c