Copy link to clipboard
Copied
Hi, I need help to implement into code bellow, ok: function for "ok" button to write data from input field into text field and other; function for reset button to reset or write 0 into same text field.
var CustomDialog = {
description: { name: "Some Name", elements: [
{ name: "Some text", type: "static_text", },
{ type: "cluster", elements: [
{ name: "Some text", type: "static_text", },
] },
{ type: "cluster", align_children: "align_row", elements: [
{ name: "Some text", type: "static_text", },
{ item_id: "usnm", type: "edit_text", char_width: 4, },
]},
{ type: "ok_cancel_other",
ok_name: "Ok",
cancel_name: "Cancel",
other_name: "Reset" },
] }
};
app.execDialog(CustomDialog);
1 Correct answer
Use this:
var dialogReturnValue = app.execDialog(CustomDialog);
if ("ok" == dialogReturnValue) {
this.getField("textfield").value = CustomDialog.strName;
} else if ("other"==dialogReturnValue) {
this.getField("textfield").value = "0";
}
Copy link to clipboard
Copied
The execDialog method returns the value selected, so you can do it like this:
if (app.execDialog(CustomDialog)=="ok") {
// do something
} else {
// do something else
}
Copy link to clipboard
Copied
Sry can you help me more I'm not sure what to write there?
Copy link to clipboard
Copied
I still have trouble with this can someone help pls?
Copy link to clipboard
Copied
You're missing a lot of code. For starters, you're not using the commit function of the dialog object to save the value the user entered to a variable. If you did that you could then apply it to a field when "ok" is clicked.
Copy link to clipboard
Copied
Thanks for explanation I'm new to this and not have a clue what I'm doing.
Copy link to clipboard
Copied
Hi, I managed to get things working just having few more issue,
I got ok button to work but i'm having problem with (other_button) called "Reset"
this is codes I used
commit: function(dialog)
{
var data = dialog.store();
this.strName = data["usnm"];
},
other: function(dialog){
dialog.end();
this make "Reset" to close Dialog box now I need also to write "0" to textfield
this is what I used
CustomDialog.strName = this.getField("textfield").value;
if("ok" == app.execDialog(CustomDialog))
{
this.getField("textfield").value = CustomDialog.strName;
}else{
this.getField("textfield").value = "0";
}
This write 0 to textfield but it also write 0 even if I press cancel. What do I need to add to specify "Reset" button only to write 0?
Copy link to clipboard
Copied
Use this:
var dialogReturnValue = app.execDialog(CustomDialog);
if ("ok" == dialogReturnValue) {
this.getField("textfield").value = CustomDialog.strName;
} else if ("other"==dialogReturnValue) {
this.getField("textfield").value = "0";
}
Copy link to clipboard
Copied
Edited: Thank you so much it worked just need to change
this
if ("other"==dialogReturnValue)
to this
if ("other" == dialogReturnValue)
and it's working fine,thanks again.

