Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session
SOLVED

Opening an external file containing javascript code

Avatar

Level 2

I'm trying to develop a PDF in two languages. When pushing a button, all questions and list-of-values for possible answers should be translated.

I created and initialized several variables with the two language phrases with javascript. Everything is inside my code.

Is there anyway that when a button is pressed an external file is read, bringing that javascript code for questions ans list-of-values? My concern is that currently I have a duplicated code, but if I want to implement three, four languages it will grow without control.

This is an example I wrote in my code:

var TxtAuxL1ESP = new Array();

var TxtAuxL1ING = new Array();

TxtAuxL1ESP[0]=", como ";

TxtAuxL1ING[0]=", such as ";

TxtAuxL1ESP[1]=": el último año ha obtenido ";

TxtAuxL1ING[1]=": last year it obtained ";

TxtAuxL1ESP[2]="%, en los últimos tres años ";

TxtAuxL1ING[2]="%, in the last three years ";

TxtAuxL1ESP[3]="% y en los últimos cinco años ";

TxtAuxL1ING[3]="% and in the last five years ";

//...

if (P1.BtnIdioma.border.edge.stroke == "raised") {

    var TxtAuxL1=TxtAuxL1ESP;

    var TxtAuxL2=TxtAuxL2ESP;

    var TxtAuxL3=TxtAuxL3ESP;

}

else {

    var TxtAuxL1=TxtAuxL1ING;

    var TxtAuxL2=TxtAuxL2ING;

    var TxtAuxL3=TxtAuxL3ING;

}

What I was thinking is to store TxtAuxL1ING in one file, TxtAuxL1ESP in another file and read them from my javascript code inside the PDF. Is it possible?

Regards

JC

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

maybe this solution ist interesting for you.

It populates form fields with data read from an attached XML file.

http://thelivecycle.blogspot.de/2011/01/populate-data-from-attachment.html

View solution in original post

4 Replies

Avatar

Level 2

Anybody can help me with this question?

Avatar

Correct answer by
Level 10

Hi,

maybe this solution ist interesting for you.

It populates form fields with data read from an attached XML file.

http://thelivecycle.blogspot.de/2011/01/populate-data-from-attachment.html

Avatar

Level 2

Sorry I was not able to check your answer before, radzmar.

Yes, this is what I was looking for.

Now I have to figure out how to load that file automatically, instead of attaching manually the xml file.

Thanks for answering, radzmar!

Avatar

Former Community Member

Hi Radzmar

I am very interested in the solution you directed jcarlosd to at http://thelivecycle.blogspot.de/2011/01/populate-data-from-attachment.html

however I am unable to download the example pdf ( I assume it has expired after so long?)

Do you still have it ? Would it be possible to re upload it please?

Many Thanks

Ellis