[Scribus] Javascript ON BLUR

Maciej Hanski ma_han2000
Sat Jun 16 16:07:39 CEST 2007


Prasad Mhatre napisa?(a):
> Dear Friends,
> 
> Can someone let me know some good examples using javascript?
> 
> I need to use some validation and conversion in my forms.
> e.g. with thml form below:
>    //----- To convert User Id to Upper Case.
>    var UserId1;
>    function ChangeCase(inputform)
>     {
>     UserId1 = inputform.user_id.value;
>     inputform.user_id.value=UserId1.toUpperCase();
>     return ;
>     }
> 
> and inside the form
>              <input name="user_id" type = "text" OnBlur="ChangeCase(document.FrmLogin)" OnFocus="SelectText(this);" maxlength=20>
> 
> Is this possible with Scribus? 
> 
> Thanks
> Love and regards
> Prasad
> 

Hi Prasad and welcome to the Scribus mailing list,

a good entry point is the "PDF Forms" category within the Scribus Wiki:

http://wiki.scribus.net/index.php/Category:PDF_Forms

In particular, please check out this new article written by a nice guy
from Australia (our new Wiki author who specializes on this area, finally:):

http://wiki.scribus.net/index.php/How_to_enhance_your_PDF_forms_with_JavaScript


Now to your specific questions (beware, I'm not a javascript or pdf
forms guru, I just want to help, since there have been no other specific
responces to your questions so far):

1. You won't be able to define many forms within a PDF documents, so  a
function using inputform as an input parameter like
ChangeCase(inputform) won't make any sense in this case.

2. But you may of course define document wide JavaScript functions  in
Scribus, please go to Edit/JavaScript and add your functions there, e.g.
something like:

function RunOnLaunch()
{
	app.alert('Welcome stranger');
}

You may  call these functions then while opening a pdf document
(onlaunch), just go to "File/Save as PDF/Viewer/SpecialActions" and
choose a Javascript function to be executed. You may as well call these
functions from within your PDF form elements (text fields, buttons,
etc.) -- see below.

3. To define what should happen e.g. onBlur, right click on an PDF form
element, select "PDF options/Field properties/Action" tab, specify
JavaScript as Action Type and choose e.g. "OnBlur" from the drop down
list. The last thing to do is to click on "Edit..." and define your
actions, either by writing your code within this very element or by
calling one of your document wide functions. E.g. to change everything
in your user_id field to upper case, you could do sth like this (just
tested, works with Scribus 1.3.4):

	this.getField("user_id").value=this.getField("user_id").value.toUpperCase();

4. Important: PDF forms support has been broken in the last 2 stable
Scribus releases (1.3.3.8 and 1.3.3.9) so please either use an older
version (e.g. 1.3.3.7), or use the unstable branch 1.3.4 and accept the
risks, or just wait until the issues in question are fixed.

hth somehow
Maciej













More information about the scribus mailing list