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

how can I modify this script?

Explorer ,
Aug 02, 2019 Aug 02, 2019

Copy link to clipboard

Copied

Can someone tell me if I can modify this code or if I need to use a different one? I'm using this script to formulate different text fields into one text field. It works fine but I'd like to format the text a bit. I'm using Centered (but that doesn't have anything to do with anything). I'd like to be able to double or even triple space in the destination field. When I hit the Return key the text moves down but as soon as I click outside the field the text jumps back up and doesn't allow me to format the lines of text as I would like. Or to even type in additional text into the field. What I did to get around that, is I created an additional text field that I can type into it (see my example script Text31).

Here's the script:

event.value = this.getField("blank").value  + " \n" +

    this.getField("WeInstall").value  +"" +

    this.getField("TotAllFootage").value  +"" +

    this.getField("Of").value  +

    this.getField("Height").value +  " " +

    this.getField("Type").value +  "\n\n" +

   

    this.getField("GateNumberA").value + "  " +

    this.getField("Text32").value +  " " +

    this.getField("NewFenLineA").value +  "\n" +

    this.getField("GateNumberB").value +  "  " +

    this.getField("Text32B").value +  " " +

    this.getField("NewFenLineB").value +  "\n" +

    this.getField("GateNumberC").value +  "  " +

    this.getField("Text32C").value + " " +

    this.getField("NewFenLineC").value +"\n" +

    this.getField("GateNumberD").value + "" +

    this.getField("Text32D").value + " " +

    this.getField("NewFenLineD").value +   "\n\n\n          " +

   

    this.getField("TermPoSpecs").value +  " " +

    this.getField("TermPostDiam").value +  " \n" +

    this.getField("LPSpecs").value +  " " +

    this.getField("LinePostDiam").value +  " \n   " +

   

    this.getField("RailSpecs").value +  " " +

    this.getField("TopRailDiam").value +  " \n\n\n" +

    

    this.getField("FootingsDuo").value +  "\n\n" +

    this.getField("Text31").value +  "\n\n"

So, is it possible to use this script, modify it and eliminate Text31 field? Can someone chime in and let me know how? Thank you very much.

TOPICS
Acrobat SDK and JavaScript , Windows

Views

278

Likes

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 , Aug 02, 2019 Aug 02, 2019

You can't edit the value of a calculated script (well, at least not easily), as the calculation will simply override your changes, as you've seen.

I don't quite understand what you're trying to achieve in terms of formatting that your code doesn't already do... Please elaborate.

Likes

Translate

Translate
Community Expert ,
Aug 02, 2019 Aug 02, 2019

Copy link to clipboard

Copied

You can't edit the value of a calculated script (well, at least not easily), as the calculation will simply override your changes, as you've seen.

I don't quite understand what you're trying to achieve in terms of formatting that your code doesn't already do... Please elaborate.

Likes

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
Explorer ,
Aug 02, 2019 Aug 02, 2019

Copy link to clipboard

Copied

Heya Gilad, thanks for getting back to me on this. What I was wanting to do is to control how the text is displayed when it's called into the destination text field. As it stands now, let's say, the FootingsDuo drop down field is a long description. And, when it's called into the destination field it goes from edge to edge of the field. As you can see, I've used the "\n and \n\n" to control the line spacing of the next text field. I've also tried to use the \n in the drop downs but that only spaced the lines in the drop down. That doesn't look good so I don't want to use that method of spacing the text. So, that leaves me with the script above.

Also, I cannot type any additional text into the destination field. If I try to type text into the field it just gets wiped out. The way I found that enables me to type in additional text is to have a separate text field and call it in from this script. That works but it's really not what I want to do nor does it make sense. One should be able to type right into the field. Anyway, any suggestions or am I outta luck? Thanks again for your time.

Likes

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 ,
Aug 03, 2019 Aug 03, 2019

Copy link to clipboard

Copied

I'm sorry, I still don't understand what you're trying to achieve... Maybe if you could share a sample file that demonstrates it it will be more clear.

And yes, you can overwrite a calculated value of a field with a manually entered value, but you need to clearly define how it should work. For example, if the user then goes back and edits one of the "source" fields, should it overwrite the manually entered value, or not?

Likes

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
Explorer ,
Aug 05, 2019 Aug 05, 2019

Copy link to clipboard

Copied

LATEST

Heya Gilad, sorry for the delay getting back to you, I had other things I had to take care of. Anyway, what I did to fix up this issue was I simply put another text field on top of the other one and I show and hide it. It works and allows me to enter and space the text I enter. It's not too complicated and it works for me. I just want to thank you again for all your help thru the years.

Likes

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