[Scribus] Duplicate field values in FORM using Javascript?

Maciej Hanski ma_han2000
Tue Jun 19 21:50:23 CEST 2007


Prasad Mhatre napisa?(a):
> Dear Friends,
> 
>  Is it possible to duplicate the field values entered in a form?
> Suppose I have two fields (viz. FirstName and another field Name) where one
>  enters FirstName the second field Name is to be entered automatically, i.e.
>  Second Name may not be entered, in this Name field the content of FirstName
>  should be replicated.
> 
>  It sounds strange, why two fields should contain the same information, but 
> I
>  need this on a form where there is an acknowledgment slip which contains 
> the
>  Name, and I expect no one should enter the same information again.
> 

Dear Prasad,
I strongly encourage you to have a read of some of the docs mentioned in
my earlier post, e.g. these two sources:

http://wiki.scribus.net/index.php/How_to_enhance_your_PDF_forms_with_JavaScript
http://www.acrobatusers.com/tech_corners/javascript_corner/tips/index.php?sort=true&search_keyword=All


As for copying field values:

1. Create two fields "text1" and "text1_copy"

2. Go to the PDF Properties of the "text1_copy" field, and click on the
"Calculate" tab.

3. Select "Custom script" and insert this line there:

	event.value = this.getField("text1").value;

4. Since this copying action will be performed on leaving the "text1"
field first, you could consider creating a dummy button called "Copy
field values" (go to the Story Editor to enter this button description,
btw) or something like this, just to force users to click on it to
ensure, the last field will be copied too.

5. You might as well put all the copying actions into one document wide
script and call this script from a "Copy field values" button (remember
my explanations about document wide scripts in our "onBlur"
conversation?). In this case, you would have to write
this.getField("text1_copy").value = this.getField("text1").value instead
of event.value for each field to be copied.

hth
Happy experimenting
Maciej



More information about the scribus mailing list