Skip to main content
Inspiring
July 22, 2020
Answered

need help Javascript

  • July 22, 2020
  • 1 reply
  • 1045 views

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);

 

This topic has been closed for replies.
Correct answer try67

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?

 


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";
}

1 reply

try67
Community Expert
Community Expert
July 22, 2020

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

}

Asim123Author
Inspiring
July 22, 2020

Sry can you help me more I'm not sure what to write there?

Asim123Author
Inspiring
July 22, 2020

I still have trouble with this can someone help pls?