Java script - how to add new fields (gouped obcjects) by clicking button

Previous topic - Next topic

Bodom

Hello Scribus Community

I need to create PDF form. I need in one place to give users a chance to add new fields (if there are more than one motive).
Design isn't important in my example at the moment (I will take care about that when I figure how to solve this issue) but for further java script code I called my grouped objects that I want to be copied "MOTIVE". In attached picture "MOTIVE" is that gray bar with "Motive name" , "Quantity", "Height (cm)", "Width (cm)" fields. Button "ADD NEW MOTIVE" isn't grouped with "MOTIVE"- its above it. I wish to add js to this button to simply create/copy "MOTIVE" object just below (without any gap). New object should contain "REMOVE" button (maybe "ADD NEW MOTIVE" should just put below some hidden object- lets say "MOTIVE 2" already with "REMOVE" button?). Each REMOVE should delete just his own MOTIVE.

I'm not familiar with Java Srcipt at all, but I was intense looking on the web for some solution or just example code to modify.
I've found some solution that is perfect for me (If I only know how to use my "MOTIVE" category it this code) but simply I just don't know how to implement this "add fields" function to my case"

here is this code with demo of it:
http://jsbin.com/cubihomapo/edit?html,js,output

I'm really confused (as JS noob) how to avoid html apperance in java script code for Scribus.
Can anyone give me some advices how to start? Or maybe someone had similar problem and found solution? I'm not asking for ready code but for some tips for begginer- how to copy existing object (MOTIVE) in desided place by clicking button. Of course if someone can put here working code that would be super.

Hope that is possible in Scribus- If definietly not- please let me know- this is urgent task for me so maybe should I search for other tool. (It has to be one file- PDF- without any additional files- my boss don't want me to code such form in html/css/js which I found easier with many html/css/js forums. So I decided to use Scribus with some JS magic:))

[attachment deleted by admin]

GarryP

Welcome to the forum Bodom.

I don't use the scripting functions myself but I would guess that what you want to do would be very difficult in Scribus.
It might be possible to add fields or it might be possible to reveal hidden fields but getting that working predictably will probably take a lot of effort, if it is at all possible.
PDFs are generally about fixed-size pages and making something that will add stuff to a page dynamically isn't really something that Scribus was designed for.

I would personally recommend using another tool.

I don't know why you have been given the restrictions you have but there will probably be other - much better - ways of doing it. A web search for "how to create an interactive pdf form" might get you somewhere. I might be totally wrong but I think that trying to get Scribus to do what you want might take too much time.

Bodom

Hello GarryP,

Thank for your reply. You just confirmed my worries about whole thing:)
I was looking long time for good tool to do it but demand for "dynamic" features appears when I already started to use Scribus. Before I was aiming rather html solutions- but I was stopped in searching:)
You're right- changing dynamicly size and composition of such PDF form would be extremly problematic.

I'm going to talk with my boss once again about html/css/js form and try to convience him to put it on our server or smth. Even as "coding" newbie I found many helpfull ready codes to modify for such form- with all desired features.

Anyway- thanks again for your time:)

GarryP

You're welcome.

If you must use a PDF for this - for whatever reason - then you're either going to have to put in a lot of time and effort to get Scribus to do what you want - if it is possible at all - or you will have to use something else.
Only a very small proportion of Scribus users use the scripting functions so getting help and advice will probably take a long time. Since you have said that your task is urgent then that's probably not going to be good enough.
Personally I would be thinking about getting a trial version of Acrobat DC.

If you don't need it to be a PDF then I'm sure there will be many other options but it all depends on the lifespan of the form and how it's going to be used.
Since I don't know how the information will be exchanged/extracted/stored/processed I can't really give any advice.

I'm sure that there will be plenty of on-line services that will let you do what you want - try searching for "online survey" - but you might have to pay for them. It's worth having a look anyway as it might save you a lot of extra work/hassle since these companies will have done most of the work for you.

Anyway, good luck.