Skip to main content
Known Participant
August 2, 2019
Answered

how can I modify this script?

  • August 2, 2019
  • 1 reply
  • 1174 views

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.

This topic has been closed for replies.
Correct answer try67

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.

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
August 2, 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.

pdfUser1Author
Known Participant
August 3, 2019

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.

try67
Community Expert
Community Expert
August 3, 2019

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?