0
Enthusiast
,
/t5/indesign-discussions/i-cant-save-script-ui-setting-using-script-labels/td-p/13131206
Aug 12, 2022
Aug 12, 2022
Copy link to clipboard
Copied
Hello Experts, please help me to identify the problem, it doesnt save user entries when selecting from dropdown index!, i dont know what wrong i do?! , its my first time trying to save user setting from UI, here is the simple code :
//Save User UI Setting
var savedUISettings = eval(app.extractLabel("usersettings"));
//Simple Dialog
var doc = app.documents[0];
var w = new Window ("dialog");
w.preferredSize.width = 320;
w.text = "Select Currency";
var myBinding = [
"Ignore",
"Right to Left",
"Left to Right"
];
var myCurrecy = [
"$",
"£",
"€",
"Â¥"
];
var myTitle = w.add ("statictext", undefined, "Select Your Binding and Currenc :");
var myDropdown1 = w.add ("dropdownlist", undefined, myBinding);
var myDropdown2 = w.add ("dropdownlist", undefined, myCurrecy);
myDropdown1.selection = 1;
myDropdown2.selection = 3;
//Buttons
var buttons = w.add ("group")
buttons.add ("button", undefined, "OK");
buttons.add ("button", undefined, "Cancel");
var a = w.show()
if(a == 2){
exit(0);
// Save UI User Settings
var userChoice = {
myDropdown1 : myDropdown1.selection,
myDropdown2 : myDropdown2.selection,
}
app.insertLabel("usersettings", userChoice.toSource());
}
Best
Mohammad Hasanin
Mohammad Hasanin
TOPICS
Scripting
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
1 Correct answer
Community Expert
,
Aug 12, 2022
Aug 12, 2022
Here's how I would do it:
//Save User UI Setting
var savedUISettings = eval(app.extractLabel("usersettings"));
if (!savedUISettings) {
savedUISettings = [0,0];
}
//Simple Dialog
var doc = app.documents[0];
var w = new Window ("dialog");
w.preferredSize.width = 320;
w.text = "Select Currency";
var myBinding = [
"Ignore",
"Right to Left",
"Left to Right"
];
var myCurrecy = [
"$",
"£",
"€",
"Â¥"
]
...
Community Expert
,
/t5/indesign-discussions/i-cant-save-script-ui-setting-using-script-labels/m-p/13131421#M488145
Aug 12, 2022
Aug 12, 2022
Copy link to clipboard
Copied
Here's how I would do it:
//Save User UI Setting
var savedUISettings = eval(app.extractLabel("usersettings"));
if (!savedUISettings) {
savedUISettings = [0,0];
}
//Simple Dialog
var doc = app.documents[0];
var w = new Window ("dialog");
w.preferredSize.width = 320;
w.text = "Select Currency";
var myBinding = [
"Ignore",
"Right to Left",
"Left to Right"
];
var myCurrecy = [
"$",
"£",
"€",
"Â¥"
];
var myTitle = w.add ("statictext", undefined, "Select Your Binding and Currenc :");
var myDropdown1 = w.add ("dropdownlist", undefined, myBinding);
var myDropdown2 = w.add ("dropdownlist", undefined, myCurrecy);
myDropdown1.selection = savedUISettings[0];
myDropdown2.selection = savedUISettings[1];
//Buttons
var buttons = w.add ("group")
buttons.add ("button", undefined, "OK");
buttons.add ("button", undefined, "Cancel");
if (w.show()) {
var userSettings = [myDropdown1.selection.index, myDropdown2.selection.index];
app.insertLabel("usersettings", (userSettings.toSource()));
}
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
M.Hasanin
AUTHOR
Enthusiast
,
LATEST
/t5/indesign-discussions/i-cant-save-script-ui-setting-using-script-labels/m-p/13131559#M488157
Aug 12, 2022
Aug 12, 2022
Copy link to clipboard
Copied
@brian_p_dts , That was smart!, Thanks a lot for your help, i wish you a great day
Best
Mohammad Hasanin
Mohammad Hasanin
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

