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

need help Javascript

Enthusiast ,
Jul 22, 2020 Jul 22, 2020

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

 

TOPICS
Acrobat SDK and JavaScript

Views

491

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 , Jul 23, 2020 Jul 23, 2020

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

Votes

Translate

Translate
Community Expert ,
Jul 22, 2020 Jul 22, 2020

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

}

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
Enthusiast ,
Jul 22, 2020 Jul 22, 2020

Copy link to clipboard

Copied

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

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
Enthusiast ,
Jul 22, 2020 Jul 22, 2020

Copy link to clipboard

Copied

I still have trouble with this can someone help pls? 

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 ,
Jul 22, 2020 Jul 22, 2020

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.

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
Enthusiast ,
Jul 22, 2020 Jul 22, 2020

Copy link to clipboard

Copied

Thanks for explanation I'm new to this and not have a clue what I'm doing. 

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
Enthusiast ,
Jul 23, 2020 Jul 23, 2020

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?

 

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 ,
Jul 23, 2020 Jul 23, 2020

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

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
Enthusiast ,
Jul 23, 2020 Jul 23, 2020

Copy link to clipboard

Copied

LATEST

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.

 

 

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