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

dialog box help

Community Beginner ,
Jan 30, 2021 Jan 30, 2021

Copy link to clipboard

Copied

Need little help, I'm trying to adapt code i found online and  i'm struggling how to export fruit name to 'Text1' field? Also what numbers +1,-2,-3 represent and how to use them?

I'm getting error: 'object aggregate'

var dlg1 = {
initialize: function(dialog) {
this.loadDefaults(dialog);
},
commit: function(dialog) {
var data = dialog.store();
this.strName = data["sub1"];
},
loadDefaults: function (dialog) {
dialog.load({
sub1:
{
"Apple": +1,
"Orange": -2,
"Kiwi": -3
}
})
},
description:
{name: "Fruits",elements:[
{type: "view",align_children: "align_left",elements:[
{type: "cluster",name: "Select fruit",elements:[
{type: "popup",item_id: "sub1",width: 200,},
]},
{type: "ok_cancel"}
]}
]}
}
var dialogReturnValue = app.execDialog(dlg1);
if ("ok" == dialogReturnValue) {
this.getField("Text1").value = dlg1.strName;}

TOPICS
JavaScript

Views

548

Translate

Translate

Report

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

Community Expert , Jan 30, 2021 Jan 30, 2021

Did you follow the example? Notice that i returns the text, while elements[i] returns the number.

Votes

Translate

Translate
Community Expert ,
Jan 30, 2021 Jan 30, 2021

Copy link to clipboard

Copied

The numbers represent the export value of the various items in it, with the positive one being the item selected by default.

Have a look at example 3 under the documentation of the execDialog method to see how to correctly parse the selected value of a popup field.

 

Votes

Translate

Translate

Report

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
Community Beginner ,
Jan 30, 2021 Jan 30, 2021

Copy link to clipboard

Copied

Thank you for that explanation.

Yea i'm looking at that example for few hours and can't figure it out,

// This dialog box is called when the OK button is clicked.
commit: function(dialog) {
// See the Dialog object for a description of how dialog.load
// and dialog.store work.
var elements = dialog.store()["subl"];
// do something with the data. <--- am i missing something here?

Votes

Translate

Translate

Report

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
Community Expert ,
Jan 30, 2021 Jan 30, 2021

Copy link to clipboard

Copied

Yeah, that part is not very clear, but look at the butn function... It shows how to read the value from that field.

Votes

Translate

Translate

Report

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
Community Beginner ,
Jan 30, 2021 Jan 30, 2021

Copy link to clipboard

Copied

I managed to make it work but am getting numbers instead of text value. What do I need to change to get word instead of number?

Votes

Translate

Translate

Report

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
Community Expert ,
Jan 30, 2021 Jan 30, 2021

Copy link to clipboard

Copied

Did you follow the example? Notice that i returns the text, while elements[i] returns the number.

Votes

Translate

Translate

Report

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
Community Beginner ,
Jan 30, 2021 Jan 30, 2021

Copy link to clipboard

Copied

LATEST

Ahh, that was the problem, thank you so much for help.

Votes

Translate

Translate

Report

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