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

Drop Down menu if condition

Participant ,
Jun 21, 2021 Jun 21, 2021

I want to Select Black And its show Black in Dropdown menu, when i click dropdown menu its show red only---

 

Step 1:- I Select Black in Drop Down Menu

Step 2:- Alert:- You have selected Black

 

My If condition is not satisfied, How to put right condition of if 

 

var dlgMain = new Window("dialog","CCCCCCC", undefined, { closeButton:true} )
dlgMain.marginLeft = 15;
dlgMain.center();
dlgMain.orientation = "row";

var dropdown7_array = ["Black","Red","White","Blue","Green"];
var dropdown7 = dlgMain.add("dropdownlist", undefined, undefined, {name: "dropdown7", items: dropdown7_array});
dropdown7.selection = 0;

dlgMain.show();

if(dropdown7.selection==dropdown7.items);
{
alert("red");
}

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

LEGEND , Jun 21, 2021 Jun 21, 2021

I extended my code of .text, so now you can use conditions to check chosen color name.

Translate
Adobe
Explorer ,
Jun 24, 2021 Jun 24, 2021
// DIALOG
// ======
var dialog = new Window("dialog");
    dialog.text = "Color Nippon";
    dialog.orientation = "column";
    dialog.alignChildren = ["center","top"];
    dialog.spacing = 10;
    dialog.margins = 16;

// PANEL1
// ======
var panel1 = dialog.add("panel", undefined, undefined, {name: "panel1"});
    panel1.text = "Color Change";
    panel1.orientation = "column";
    panel1.alignChildren = ["left","top"];
    panel1.spacing = 10;
    panel1.margins = 10;

var statictext1 = panel1.add("statictext", undefined, undefined, {name: "statictext1"});
    statictext1.text = "Please choose color";

var dropdown1_array = ["Choose","BS 9102","OW001","OW002","OW003","OW004","OW005","OW006","OW007","OW008"];
var dropdown1 = panel1.add("dropdownlist", undefined, undefined, {name: "dropdown1", items: dropdown1_array});
    dropdown1.selection = 0;
    dropdown1.preferredSize.width = 100;
    dropdown1.alignment = ["center","top"];

var button1 = panel1.add("button", undefined, undefined, {name: "button1"});
    button1.text = "Ok";
    button1.alignment = ["center","top"];
    button1.onClick = function(){
    dialog.close()
      $.evalFile(File($.fileName).parent.fsName  + "/folder_color/"+ dropdown1.selection+".jsx");
   alert(dropdown1.selection);
 }
dialog.show();

please help me to fix the above code error, can't get the dropdown1.selection value, I put the dropdown1.selection value in “+ dropdown1.selection +” there is an error

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
LEGEND ,
Jun 24, 2021 Jun 24, 2021
dropdown1.selection.text
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
Explorer ,
Jun 24, 2021 Jun 24, 2021

Thank you for supporting me

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
Mentor ,
Jun 24, 2021 Jun 24, 2021

typeof dropdown1.selection == 'object'

 

use dropdown1.selection.toString() or dropdown1.selection.text

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
LEGEND ,
Jun 24, 2021 Jun 24, 2021

Or:

 

unescape(dropdown1.selection)

 

You can also check few things by:

 

uneval(dropdown1.selection)

 

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
Explorer ,
Jun 24, 2021 Jun 24, 2021

Thank you 

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
LEGEND ,
Jun 24, 2021 Jun 24, 2021

Your thread has been merged with other referring to same question. If you're 1st time posting, don't forget next time to use Correct Answer button, so other users may find help much faster.

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