Scribus > PDF Generation

PDF Form Java Script to transfer values of Check Box to a Text Field in a proper

(1/2) > >>

durmul:
Inspired by a video on PDF Form javascript to transfer values of Checkbox to a text field in a proper listed format
I tried to name the checkbox field in a sequence manner cHob.01, but dot(.) is not accepted in name field of checkbox, I then named my name field sequence in cHob1, cHob2, cHob3 and then I created the declared variables and set an array as described in video here is the code, but its not working
var items = [ ];

for (i = 0; i<10; i++) {

var Hobbies = this.getField("cHob1"+ i);

if (Hob.value !="Off"){

items.push(items.length+1 + ". " + Hob.value);
event.value = "Your Hobbies are listed below: "+  "\n" + items.join("\n");
}
if(items.length<=0) {event.value = " "}
}

The above code works fine in acrobat dc pro as in video but not in scribus.

jghali:
While I'm not a JavaScript specialist, I think this line is wrong:
var Hobbies = this.getField("cHob1"+ i);

This would likely give you cHob10, cHob11, cHob12 as field names instead of the wanted cHob1, cHob2, cHob3.

durmul:
I tried with renaming fields to cHob10 and so on also change the Item fields names to Hob10... and so on

It's not working

There was error earlier in the code rectified instead of Hobbies it should have been Hob
var items = [ ];

for (i = 0; i<19; i++) {

var Hob = this.getField("cHob10"+ i);

if (Hob.value !="Off"){

items.push(items.length+1 + ". " + Hob.value);
event.value = "Your Hobbies are listed below: "+  "\n" + items.join("\n");
}
if(items.length<=0) {event.value = " "}
}

jghali:
Again this line is wrong:
var Hob = this.getField("cHob10"+ i);

This code will not increment field names to cHob10, cHob11, cHob12, etc...

durmul:
Guide me what to write

I am also not javascript expert Just beginner

I saw the video copied it and tried to use it in scribus

Navigation

[0] Message Index

[#] Next page

Go to full version