Dropdown list open file

New Here ,
Jul 29, 2020

Copy link to clipboard

Copied

Hello Everyone,

I need your help with the dropdownlist, I have created a window where I have 2 dropdownlists, the first one I want to open specific files and the second one that I can select a background color for the file when I open it and when I click on ok the file will open selected with the selected color, how can I do this please?

TOPICS
How to, Scripting

Views

253

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

2 Correct Answers

Adobe Community Professional , Oct 28, 2020
Manan Joshi Adobe Community Professional , Oct 28, 2020
In that case try the following   var folderList = [] var files = [] function getFiles(folderPath) { var f = new Folder(folderPath) if(f.exists) { folderList.push(f.name) files[f.name] = [] f.getFiles(function(p){ if(p.constructor.name == "File") { files[f.name].push(p.name) return true; } else folderList.push(p.name) }) } } var basePath = "~/Desktop" getFiles(basePath); //Change the path of the folder whose files you want to show in the dropdown var win = new...

Likes

Translate

Translate
Jump to answer Jump to answer
Adobe Community Professional , Oct 24, 2020
Manan Joshi Adobe Community Professional , Oct 24, 2020
Hi @Juan Carlos Hdez  I modified the code on the thread to create a sample that has a dropdown populated with names of files present in a folder, hope this helps function getFiles(folderPath) { var retval = [] var f = new Folder(folderPath) if(f.exists) { f.getFiles(function(p){ if(p.constructor.name == "File") { retval.push(p.name) return true; } }) } return retval; } var files = getFiles("~/Desktop") //Change the path of the folder whose files you want to show in the...

Likes

Translate

Translate
Jump to answer Jump to answer
Adobe Community Professional ,
Jul 29, 2020

Copy link to clipboard

Copied

Hi Juan, share the code you have written so far. It's easy and takes less time to tweak an existing code rather the writing the whole solution from scratch. Also do tell where are you stuck or what problem you are facing with the code that you share.

-Manan

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
Aug 02, 2020

Copy link to clipboard

Copied

This is the code that I have at the moment, I know that it has errors and unnecessary code lines, but if it can be simplified I would greatly appreciate your help, if you do not understand what I want with this let me know although I will upload some photos with the diagram of the functions to do. Thank you very much in advance.

 

 

if (app.documents.length > 0) // Continuar si al menos hay un documento abierto.
{


/////// * Documento activo. * ///////
var doc = app.activeDocument;

/////// * Inicio de la Interface. * ///////
var win = new Window('dialog','Creador de Facturas'); //win.helpTip = "\u00A9 2018 Juan C. Hernández";
win.alignChildren = "row"

/////// * En esta zona se define el nombre del tipo de número a crear. * ///////
var newGroup2 = win.add("panel", undefined, 'Por favor seleccione:');
var newGroup1 = newGroup2.add("group");
var txtName = newGroup1.add("statictext",undefined,"Tipo de Factura:");
(factName = newGroup1.add("dropdownlist", undefined, FontType)); factName.characters = 50; factName.helpTip = "Ingrese el tipo de Factura";

newGroup2.alignment = "left";
newGroup2.alignChildren = "left";
newGroup1.size = [358,30];
factName.size = [200,25];

/////// * Hace un array para la lista desplegable del tipo de factura. * ///////

win.listPnl = win.add('panel', undefined, 'Por favor seleccione:');
newGroup1 = win.listPnl.add("group");
txtName = newGroup1.add("statictext",undefined,"Tipo de Factura:");
win.listPnl.selectList = newGroup1.add("dropdownlist");
win.listPnl.selectList.add("item", "FACTURA 1");
win.listPnl.selectList.add("item", "FACTURA 2");
win.listPnl.selectList.add("item", "FACTURA 3");
win.listPnl.selectList.add("item", "FACTURA 4");
win.listPnl.selectList.add("item", "FACTURA 5");


win.listPnl.alignment = "left";
win.listPnl.alignChildren = "left";
newGroup1.size = [358,30];
win.listPnl.selectList.size = [200,25];

var FontType = new Array();

FontType[0] = 'FACTURA 1'
FontType[1] = 'FACTURA 2'
FontType[2] = 'FACTURA 3'
FontType[3] = 'FACTURA 4'
FontType[4] = 'FACTURA 5'


for ( i = 0; i < FontType.length; i += 1) {
FontType["_"+FontType] = i;
}

/////// * Define cuales tamaños serán usados * ///////
var Sizes = win.add("panel", undefined, "Sizes :");
var newGroup3 = newGroup2.add("group"); Sizes.helpTip = "Marque la casilla del/los size que desea crear";
var Size3 = Sizes.add("checkbox",undefined,"3"); Size3.value = false; Size3.helpTip = "Factura de 3 pulgadas";
var Size4 = Sizes.add("checkbox",undefined,"4"); Size4.value = false; Size4.helpTip = "Factura de 4 pulgadas";
var Size5 = Sizes.add("checkbox",undefined,"5"); Size5.value = false; Size5.helpTip = "Factura de 5 pulgadas";
var Size6 = Sizes.add("checkbox",undefined,"6"); Size6.value = false; Size6.helpTip = "Factura de 6 pulgadas";
var Size7 = Sizes.add("checkbox",undefined,"7"); Size7.value = false; Size7.helpTip = "Factura de 7 pulgadas";
var Size8 = Sizes.add("checkbox",undefined,"8"); Size8.value = false; Size8.helpTip = "Factura de 8 pulgadas";
Sizes.size = [392,60];
Sizes.alignment = "left";
Sizes.orientation = "row";
Sizes.spacing = 15;

/////// * Define la cantidad de colores que debe tener las facturas. * ///////
var CantCLR = win.add("panel", undefined, "Cantidad de Colores:");
var CLR1 = CantCLR.add("radiobutton",undefined, "1 Color"); CLR1.enabled = false;
var CLR2 = CantCLR.add("radiobutton",undefined, "2 Colores"); CLR2.enabled = false;
var CLR3 = CantCLR.add("radiobutton",undefined, "3 Colores"); CLR3.enabled = false;
CantCLR.size = [392,60];
CantCLR.alignment = "left";
CantCLR.orientation = "row";
CantCLR.spacing = 15;


Size3.onClick = function() { if (Size3.value == true) { CLR1.enabled = CLR1.value = CLR2.enabled = CLR3.enabled = NameCRL1.enabled = true; }

else { CLR1.enabled = CLR1.value = CLR2.enabled = CLR2.value = CLR3.enabled = CLR3.value = NameCRL1.enabled = NameCRL2.enabled = NameCRL3.enabled = false;}
};

Size4.onClick = function() { if (Size4.value == true) { CLR1.enabled = CLR1.value = CLR2.enabled = CLR3.enabled = NameCRL1.enabled = true; }

else { CLR1.enabled = CLR1.value = CLR2.enabled = CLR2.value = CLR3.enabled = CLR3.value = NameCRL1.enabled = NameCRL2.enabled = NameCRL3.enabled = false;}
};

Size5.onClick = function() { if (Size5.value == true) { CLR1.enabled = CLR1.value = CLR2.enabled = CLR3.enabled = NameCRL1.enabled = true; }

else { CLR1.enabled = CLR1.value = CLR2.enabled = CLR2.value = CLR3.enabled = CLR3.value = NameCRL1.enabled = NameCRL2.enabled = NameCRL3.enabled = false;}
};

Size6.onClick = function() { if (Size6.value == true) { CLR1.enabled = CLR1.value = CLR2.enabled = CLR3.enabled = NameCRL1.enabled = true; }

else { CLR1.enabled = CLR1.value = CLR2.enabled = CLR2.value = CLR3.enabled = CLR3.value = NameCRL1.enabled = NameCRL2.enabled = NameCRL3.enabled = false;}
};

Size7.onClick = function() { if (Size7.value == true) { CLR1.enabled = CLR1.value = CLR2.enabled = CLR3.enabled = NameCRL1.enabled = true; }

else { CLR1.enabled = CLR1.value = CLR2.enabled = CLR2.value = CLR3.enabled = CLR3.value = NameCRL1.enabled = NameCRL2.enabled = NameCRL3.enabled = false;}
};

Size8.onClick = function() { if (Size8.value == true) { CLR1.enabled = CLR1.value = CLR2.enabled = CLR3.enabled = NameCRL1.enabled = true; }

else { CLR1.enabled = CLR1.value = CLR2.enabled = CLR2.value = CLR3.enabled = CLR3.value = NameCRL1.enabled = NameCRL2.enabled = NameCRL3.enabled = false;}
};

CLR2.onClick = function() { if (CLR2.value == true) { NameCRL2.enabled = true; }

else {NameCRL2.enabled = NameCRL3.enabled =false;}
};

CLR3.onClick = function() { if (CLR3.value == true) { NameCRL3.enabled = true; }

else {NameCRL3.enabled = false;}
};

/////// * Define la posición del color elegido * ///////

var Colores = win.add("panel", undefined, "Colors");

var NameColor1 = Colores.add("statictext",undefined,"Color 1:");
var NameCRL1 = Colores.add("dropdownlist",undefined, ColorType); NameCRL1.characters = 15; NameCRL1.enabled = false; NameCRL1.helpTip = "Inserte el Nombre del Color 1";

var NameColor2 = Colores.add("statictext",undefined,"Color 2:");
var NameCRL2 = Colores.add("dropdownlist",undefined, ColorType); NameCRL2.characters = 15; NameCRL2.enabled = false; NameCRL2.helpTip = "Inserte el Nombre del Color 2";

var NameColor3 = Colores.add("statictext",undefined,"Color 3:");
var NameCRL3 = Colores.add("dropdownlist",undefined, ColorType); NameCRL3.characters = 15; NameCRL3.enabled = false; NameCRL3.helpTip = "Inserte el Nombre del Color 3";

Colores.size = [392,180];
NameCRL1.size = [200,25];
NameCRL2.size = [200,25];
NameCRL3.size = [200,25];
Colores.alignment = "left";
Colores.alignChildren = "left";
Colores.spacing = 3;

/////// * Define la cantidad de colores y sus respectivos nombres * ///////

var ColorType = new Array();
ColorType[0] = "GRAY"
ColorType[1] = "BLACK"
ColorType[2] = "RED"
ColorType[3] = "GREEN"
ColorType[4] = "MAROON"
ColorType[5] = "LIGHT YELLOW"
ColorType[6] = "LIGHT ORANGE"
ColorType[7] = "LIGHT PURPLE"
ColorType[8] = "LIGHT GREEN"
ColorType[9] = "LIGHT BLUE"



ColorType.push("-");

for (var i = 0; i < ColorType.length; i += 1) {

ColorType["_"+ ColorType] = i;
}

/////// * Panel de botones * ///////
var OptionOC = win.add ("group");

/////// * Boton Crear. * ///////
var btnCrear = OptionOC.add("button", undefined, "Crear"); btnCrear.helpTip = "Crear Factura";
btnCrear.onClick = function(){
CrearFacturas();// call main function
//win.close(); // close when done
}

/////// * Boton Cancelar. * ///////
var btnCancelar = OptionOC.add("button", undefined, "Cancelar"); btnCancelar.helpTip = "Tambien puede presionar Esc para cancelar";
btnCancelar.onClick = function () { win.close();
}

btnCrear.size = btnCancelar.size = [150,30]; // Tamaño de los 3 botones.

panelpie = win.add("group", undefined, "");
pie = panelpie.add('StaticText',{x:0,y:panelpie.maximumSize.height-10,width:20,height:12});
pie.text = '© 2018 Juan Carlos Hernández e-mail:jchd300@gmail.com';
pie.graphics.font = ScriptUI.newFont ('Tahoma', 'REGULAR', 10);
pie.bounds.width = pie.preferredSize.width;

/////// * Proceso de ejecucion del script. * ///////
function CrearFacturas() { // Función llama a ejecutar el resto del script cuando precionamos el boton crear.

if (factName)
Factura = factName.selection.index;
//else
//swatchSet = new Array();

Factura[0] = app.open(File("C:/Users/sublimation/Desktop/Test/FACTURA 1.ai"));

Factura[1] = app.open(File("C:/Users/sublimation/Desktop/Test/FACTURA 2.ai"));

Factura[2] = app.open(File("C:/Users/sublimation/Desktop/Test/FACTURA 3.ai"));

Factura[3] = app.open(File("C:/Users/sublimation/Desktop/Test/FACTURA 4.ai"));

Factura[4] = app.open(File("C:/Users/sublimation/Desktop/Test/FACTURA 5.ai"));

}


/*for(var count1= 0; count1 <= 28; count1++)
{*/
app.activeDocument.selection = false
app.activeDocument.layers[0].hasSelectedArtwork = true;

var items = selection;
var totalSelected = items.length;

for(var j=0; j < totalSelected; j++)
{
var currentObject = app.activeDocument.selection[j];
//currentObject.filled=true
//currentObject.pathItems[1].fillColor=Color[count1];
}

/*for(var count2=0; count2 <= 28; count2++)
{
app.activeDocument.selection = false
app.activeDocument.layers[1].hasSelectedArtwork = true;

for(var j=0; j < totalSelected; j++)
{
var currentObject = app.activeDocument.selection[j];
currentObject.filled=true
currentObject.pathItems[0].fillColor=Color[count2];
} */




app.redraw();


win.center(); // Centra los elementos de la ventana de ejecución.
win.show(); // Muestra la ventana de ejecución.

} else { alert ("Debe abrir por lo menos 1 documento por favor"); // Si no hay un documento abierto saldra este mensaje.
}

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
Aug 02, 2020

Copy link to clipboard

Copied

Factura Sripts-01.pngFactura Sripts-02.png

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
Aug 02, 2020

Copy link to clipboard

Copied

I am using two dropdownlists to tell me which one is better to use or which of the two should be eliminated, on the other hand the sequence of actions that the teacher wants is that when selecting for example: invoice 1 the code stops in the folder where there is this invoice, then when selecting the size or sizes that have to be opened, then when selecting the colors, color 1 must go on layer 1, color 2 on layer 2 ...., if it is a color, you only have to put a color if they are 2 put two colors according to the selection, then when pressing the create button the invoice must be opened 1> 4 inch or 4 and 5 inches and it will put the selected color or colors and saved in the folder where the files.

 

let me know if this is clear to you please.

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
Aug 06, 2020

Copy link to clipboard

Copied

Can someone please help me with this?

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Enthusiast ,
Aug 07, 2020

Copy link to clipboard

Copied

Salut Juan!

Peut-être une petite aide pour la première dropdownlist...

 

if (app.documents.length > 0) // Continuar si al menos hay un documento abierto.
{
var FontType = ['FACTURA 1','FACTURA 2','FACTURA 3','FACTURA 4','FACTURA 5'];

/////// * Documento activo. * ///////
var doc = app.activeDocument;
/////// * Inicio de la Interface. * ///////
var win = new Window('dialog','Creador de Facturas');
    win.alignChildren = "row"
/////// * En esta zona se define el nombre del tipo de número a crear. * ///////
var factPnl = win.add("panel", undefined, 'Por favor seleccione:');
    //factPnl.alignment = "left";
var newGroup1 = factPnl.add("group");
    newGroup1.size = [358,30];
var txtName = newGroup1.add("statictext",undefined,"Tipo de Factura:");
var factName = newGroup1.add("dropdownlist", undefined, FontType);
    factName.characters = 50; factName.helpTip = "Ingrese el tipo de Factura";
    factName.size = [200,25];
    factName.selection = 0;
//-----
function CrearFacturas() { // Función llama a ejecutar el resto del script cuando precionamos el boton crear.
if (factName)
Factura = factName.selection.text;  alert(factName)
alert("~/Desktop/Test/"+Factura+".ai")
 app.open(File("~/Desktop/Test/"+Factura+".ai"));
}
//-----


/////// * Hace un array para la lista desplegable del tipo de factura. * ///////

/*win.listPnl = win.add('panel', undefined, 'Por favor seleccione:');
newGroup1 = win.listPnl.add("group");
txtName = newGroup1.add("statictext",undefined,"Tipo de Factura:");
win.listPnl.selectList = newGroup1.add("dropdownlist");
win.listPnl.selectList.add("item", "FACTURA 1");
win.listPnl.selectList.add("item", "FACTURA 2");
win.listPnl.selectList.add("item", "FACTURA 3");
win.listPnl.selectList.add("item", "FACTURA 4");
win.listPnl.selectList.add("item", "FACTURA 5");


win.listPnl.alignment = "left";
win.listPnl.alignChildren = "left";
newGroup1.size = [358,30];
win.listPnl.selectList.size = [200,25];
for ( i = 0; i < FontType.length; i += 1) {
FontType["_"+FontType] = i;
} */

/////// * Define cuales tamaños serán usados * ///////
var Sizes = win.add("panel", undefined, "Sizes :");
var newGroup3 = Sizes.add("group"); Sizes.helpTip = "Marque la casilla del/los size que desea crear";

 

 

 

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
Aug 10, 2020

Copy link to clipboard

Copied

Hi,

Now I only need to be able to add the colors to each object through the dropdown list, I just need an example of how it is done.

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
Aug 10, 2020

Copy link to clipboard

Copied

Capture.PNGDropDown List.PNGLayers by color.PNGSwatches list on script.PNGSwatches list.PNG

 

I know that it is easy for you who have been working with this for a long time so I need your great help please, how can I do that from the dropdown list 1 color is applied for each layer and how would it be best if from the list of swatches or creating the list inside the script, I want to understand how the dropdown works and it is the only way I can understand if you help me with this or give me an example about this that the teacher wants please.

Thank you very much,
Juan Carlos

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Adobe Community Professional ,
Aug 06, 2020

Copy link to clipboard

Copied

Hola Juan, sorry but after reading all your instructions I'm not really sure what you need help with.

 

can you explain what you need using very few words?

 

you UI that your code creates does not match your screen shots

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
Aug 06, 2020

Copy link to clipboard

Copied

Hi Carlos,

Thanks for answering, sorry, the code does not match the screens because I edited it after capturing them.

As for what I want is that when an invoice is selected and 1 size or more sizes are opened 1 by 1, change the color or colors selected in each layer.

 

Example: Invoice 1 is a folder inside the folder it has 6 files with different sizes 3, 4, 5, 6, 7, 8.

Tipo de Factura:  (Fatura 1) =  ("C:/Users/sublimation/Desktop/Test/");  ß this is a folder.

Sizes:  (Selected) = 3, 4, 5, 6, 7, 8  ß these are files.

Cantidad de Colores: Are the colors that are going to change by layers, if you select 1 color only layer 1 changes, if you select 2 colors layer 1 and layer 2 change ...,  do not select any color = default colors.

Colores: It is to change the colors of the layers if they are selected.

When we press the (Crear) button: you must create the selected files one by one, save it in eps and artboard.

 

Let me know if you explain me well as this is a little complicated for me to say the functions that the Script should do.

 

Thanks so much.

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Adobe Community Professional ,
Aug 06, 2020

Copy link to clipboard

Copied

Hi Juan, thanks for the additional information, that's a good start. But what is the problem you're facing? what part of the code is not working? Let's deal with one question at a time

 

can you provide sample files? you're talking about Layers, we need to see the layers and oviously to test your code we need sample files

 

you haven't received any help because you haven't asked a specific question for example, "my drop down doesn't show the list I provided"

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
Oct 24, 2020

Copy link to clipboard

Copied

Hi all and renel80416020,Thank you very much for your help, my project finished very well and with this I made a lot of progress, I just want to add something else if it is possible and that is how to read the files from a folder and show the names of the files in the dropdown list without the need for write the names of the files into the code or script?

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Adobe Community Professional ,
Oct 24, 2020

Copy link to clipboard

Copied

Hi @Juan Carlos Hdez 

I modified the code on the thread to create a sample that has a dropdown populated with names of files present in a folder, hope this helps

function getFiles(folderPath)
{
	var retval = []
	var f = new Folder(folderPath)
	if(f.exists)
	{
		f.getFiles(function(p){
			if(p.constructor.name == "File")
			{
				retval.push(p.name)
				return true;
			}
		})
	}
	return retval;
}
var files = getFiles("~/Desktop")	//Change the path of the folder whose files you want to show in the dropdown
var win = new Window('dialog','Creador de Facturas');
win.alignChildren = "row"
var factPnl = win.add("panel", undefined, 'Por favor seleccione:');
var newGroup1 = factPnl.add("group");
var txtName = newGroup1.add("statictext",undefined,"Tipo de Factura:");
var factName = newGroup1.add("dropdownlist", undefined, files);
factName.selection = 0;
win.show()

-Manan

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
Oct 25, 2020

Copy link to clipboard

Copied

Hi @Manan Joshi

I have modified the code a bit, but I do not know what happened, everything was going well until it no longer works, also it should be when a folder name is chosen, the names of the files should be changed since in each folder the files are different and it is as if it stayed in a memory they do not change in the dropdown list.

 

var FontType = ['BADGER','CADET','COMBINE','FALCON','FULL BLOCK','HIGHLIGHT','PREMIER','TERRAFONT','UNDENIABLE'];


function getFiles(folderPath)
{
var retval = []
var f = new Folder(folderPath)
if(f.exists)
{
f.getFiles(function(p){
if(p.constructor.name == "File")
{
retval.push(p.name)
return true;
}
})
}
return retval;
}
var files = getFiles("~/Desktop/Test/"+factName.selection.text+""); //Change the path of the folder whose files you want to show in the dropdown
var win = new Window('dialog','Creador de Facturas');
win.alignChildren = "row"
var factPnl = win.add("panel", undefined, 'Por favor seleccione:');
var newGroup1 = factPnl.add("group");
var txtName = newGroup1.add("statictext",undefined,"Tipo de Factura:");
var factName = newGroup1.add("dropdownlist", undefined, FontType);


var factPnl1 = win.add("panel", undefined, 'Por favor seleccione:');
var newGroup2 = factPnl1.add("group");
var txtName2 = newGroup2.add("statictext",undefined,"Tamaño de Factura:");
var factSize = newGroup2.add("dropdownlist", undefined, files);

win.show()

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Adobe Community Professional ,
Oct 25, 2020

Copy link to clipboard

Copied

Hi Juan,

I tried your code, and it seems to work just fine for me. I changed the path, and it displayed the files from the new folder. See the screengrab here.

-Manan

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
Oct 27, 2020

Copy link to clipboard

Copied

Hi Manan,

I understand your point, but I think you did not understand what I want is that with the first dropdown the path is changed, for example: if I select test or demo in the first dropdown in the second the different files should be shown.

Let me know if you understand what I say. Thanks

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Adobe Community Professional ,
Oct 28, 2020

Copy link to clipboard

Copied

In that case try the following

 

var folderList = []
var files = []
function getFiles(folderPath)
{	
	var f = new Folder(folderPath)
	if(f.exists)
	{
		folderList.push(f.name)
		files[f.name] = []
		f.getFiles(function(p){
			if(p.constructor.name == "File")
			{
				files[f.name].push(p.name)
				return true;
			}
			else
				folderList.push(p.name)
		})
	}
}
var basePath = "~/Desktop"
getFiles(basePath); //Change the path of the folder whose files you want to show in the dropdown
var win = new Window('dialog','Creador de Facturas');
win.alignChildren = "row"
var factPnl = win.add("panel", undefined, 'Por favor seleccione:');
var newGroup1 = factPnl.add("group");
var txtName = newGroup1.add("statictext",undefined,"Tipo de Factura:");
var factName = newGroup1.add("dropdownlist", undefined, folderList);

factName.onChange = function(e)
{
	var selText = this.selection.text
	factSize.removeAll()
	var fList = files[selText]
	if(!fList)
		getFiles(basePath + "/" + this.selection.text)
	for(var i = 0; i < files[selText].length; i++)
		factSize.add('item', files[selText][i])
}
var factPnl1 = win.add("panel", undefined, 'Por favor seleccione:');
var newGroup2 = factPnl1.add("group");
var txtName2 = newGroup2.add("statictext",undefined,"Tamaño de Factura:");
var factSize = newGroup2.add("dropdownlist", undefined);

win.show()

 

-Manan

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Juan Carlos Hdez AUTHOR LATEST
New Here ,
Oct 28, 2020

Copy link to clipboard

Copied

Hi Manan,

Thanks you so much, 5+ Stars

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more