Script in Javascript with data and 2 checkbox?

Previous topic - Next topic

t.hai

Hi,
i need help :(
I have a file data.xfdf, who's containts the data example: p1_data_name ="Dubois", p1_data_firstname="Mark", p1_data_title="Men",...
In scribus my PDF (Test.pdf) I created the fields with name "p1_data_name" is not difficult,
but i have 2 checkbox "Women" and "Men" and i would like to open my PDF, which read the data and make true the good checkbox.

My script in Javascript:

function pret()
{
  $(document).ready(titre());
}

function titre(){
   var title = this.getField("p1_data_titre").value; //fields containts the title "Men" Or "Women"
   var men = this.getField("Men");  //checkbox Men
   var women = this.getField("Women");

   app.alert('Titre:'+title.value); // undefined at the opening pdf

   if (title.value == "Women") {
           women.value = "Yes";
           men.value = "Off";
   } else {
           women.value = "Off";
           men.value = "Yes";
   }
}

But It don't work... :(

i think the problem is that my PDF is not ready, and it make error variable not undefined.

Do you have solutions to offer me?

Sorry my language is french, sorry if there are grammar mistakes or understanding.

Thank you for read.

a.l.e

hi t

can you please share a .sla and pdf that shows the issue?

ciao
a.l.e

t.hai

Hi a.l.e,

Thank you for your help :)

And my file data.xfdf contains:

<?xml version="1.0" encoding="UTF-8"?>
<?xfa generator="T.H" APIVersion="1"?>
<xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve">
   <fields>
      <field name="p1_data_title"><value>Men</value></field>
      <field name="p1_data_name"><value>Dubois</value></field>
      <field name="p1_data_firstname"><value>Mark</value></field>
      <field name="p1_data_nele"><value>13.05.1990</value></field>
      <field name="p1_data_origine"><value>Saint-Ours</value></field>
      <field name="p1_data_ocanton"><value>FR</value></field>
      <field name="p1_data_locdl"><value>Cernier</value></field>
      <field name="p1_datasup_dateDay"><value>14.12.2016</value></field>
      <field name="p1_datasup_lieudate"><value>Neuchatel, le 14.12.2016</value></field>
   </fields>
</xfdf>

T.hai

[attachment deleted by admin]