Skip to main content
Participant
July 11, 2022
Answered

Is there a script that will duplicate each line of a multi-line form field into another form?

  • July 11, 2022
  • 1 reply
  • 773 views

Hello everybody, emergency physician here trying to help our hospital and decrease our nurse workload:

Within the same document, I am currently trying to know if there is a way to copy each single line of a multiline text ("Prescription" field) to another field (1st line to "FADM1", 2nd line to "FADM2", 3rd line to "FADM3", etc. up to FADM8).

 

For instance:

In the ''Prescription'' field, I would write :

Tylenol xxx

Naproxen xxx

Morphine xxx

 

And would like for Tylenol xxx to appear as FADM1, Naproxen xxx as FADM2 and morphine xxx as FADM 3, so on and so fort until FADM 8.

 

Do you know if it is possible via Javascript or another way?

Thanks

JS

 

 

 

 

 

This topic has been closed for replies.
Correct answer try67

The administration time will always be filled by the nurse by hand. I will not add any other field. It is way safer that way than the actual way unfortunately. Is this possible via javascript or another way? I am using a text script generator as well and the ''autotab'' function didnt work


OK, then you can use this code (at your own risk) as the custom Validation script of Text2:

 

for (var i=1; i<=8; i++) this.getField("FADM"+i).value = "";
var lines = event.value.split("\r");
for (var i=0; i<lines.length; i++) this.getField("FADM"+(i+1)).value = lines[i];

 

1 reply

try67
Community Expert
Community Expert
July 12, 2022

It's possible, but you need to be very careful, especially when it comes to medical information.

What happens if one line is missing and the wrong info is copied to the wrong cell? Or does that not matter?

try67
Community Expert
Community Expert
July 12, 2022

Another thing to consider: Let's say you added more fields in each row (say the time it should be administered), and then you edited Text2. It would re-arrange the medication names, but not the other info connected to each one (unless you set it up to reset the entire form), which can cause medicines being associated with the wrong administration times. Very dangerous stuff...

JSC2022Author
Participant
July 12, 2022

The administration time will always be filled by the nurse by hand. I will not add any other field. It is way safer that way than the actual way unfortunately. Is this possible via javascript or another way? I am using a text script generator as well and the ''autotab'' function didnt work