🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #15889

Re: DropDown in JavaScript

#15889
From: Olav_Kvern
Date: Wed, 12 Nov 2003 08:38
44 lines
2129 bytes
Ksenia--

You're looking for a list of paragraph style names in a specific document--to get that, you need to iterate through the list of paragraph styles, add the name of each style to a list, and then use that list to populate the dropdown control.

I think this example will make things a bit more clear:



//DropdownExample.js 
//Get a list of the paragraph style names from the active document (for use in the dialog box). 
var myStyleNameList = new Array(); 
for(myStyleCounter = 0; myStyleCounter < app.activeDocument.paragraphStyles.length; myStyleCounter++){ 
	myParagraphStyle = app.activeDocument.paragraphStyles.item(myStyleCounter); 
	if(myParagraphStyle.name != "[No paragraph style]"){ 
		myStyleNameList.push(myParagraphStyle.name); 
	} 
} 
//Create the dialog box. 
var myDialog = app.dialogs.add({name:"Dropdown Example"}) 
with(myDialog.dialogColumns.add()){ 
	with(dialogRows.add()){ 
		staticTexts.add({staticLabel:"Paragraph Styles:"}); 
		var myDropDown = dropdowns.add({stringList:myStyleNameList, selectedIndex:0}); 
	} 
} 
//Show the dialog box. 
var myResult = myDialog.show(); 
if(myResult == true){ 
	//Get the selected paragraph style name. 
	var myParagraphStyleName = myStyleNameList[myDropDown.selectedIndex]; 
	//Remove the dialog from memory. 
	myDialog.destroy(); 
	alert("You selected: " + myParagraphStyleName); 
}	 
else{ 
	//Remove the dialog from memory. 
	myDialog.destroy(); 
}



Thanks,

Ole
Technical Details
Message-ID: <2cce52d2.0@webx.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.tpinternet.pl!newsfeed01.sul.t-online.de!t-online.de!webx
References: <2cce52d2.-1@webx.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f939a,329521da870c4b93
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2003-11-12 01:07:35 PST
From: Olav_Kvern@adobeforums.com
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.tpinternet.pl!newsfeed01.sul.t-online.de!t-online.de!webx
Newsgroups: adobe.scripting.indesign
Subject: Re: DropDown in JavaScript
Message-ID: <2cce52d2.0@webx.la2eafNXanI>
Date: Wed, 12 Nov 2003 00:38:11 -0800
References: <2cce52d2.-1@webx.la2eafNXanI>
Lines: 47
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit