[Erp5-users] javascript in forms

Bartek Gorny bartek at gorny.edu.pl
Mon Mar 8 12:25:08 CET 2010


It depends what philosophy you want to follow. If it is Nexedi, then
the answer would probably be no, don't use javascript, handle
everything with TALES expressions and the likes, so that only when a
user saves the form he gets any information about what's required and
what is not. This would be a 'purist' aproach, so as to keep the code
clean without messing with any stupid javascript.

Take for example a parallel list field: this widget is meant to allow
a user to enter multiple values chosen from a list. What you see is a
single drop-down; when you choose a value, another empty drop-down
appears so that you can choose another value. But - the other dropdown
shows up only after you save the form. Everything is implemented in
the form's code - the implementation is very neat and clean, but if a
user has to fill five or ten values, he has to save the form five or
ten times, which can make him feel rather uncomfortable.

This is the stock implementation. It has been like that for many
years, and since it is so easy to do the same thing in
javascript/dhtml (I did it myself and it took me one day), I
understand that in Nexedi's view this is the right way to do things.

If you ask me, I'd say do the javascript; if there is anything you can
do on the client side, by all means do it. Anything that improves
responsiveness of the application is desirable. Most of my clients
using ERP5 complain about the speed - not only the server's
performance, but the speed they can themselves achieve while working
with the application. They say (a) they have to click too many times
to do their job, and (b) they have to wait too long for the server
response. To 'wait too long' often means one or two seconds, but if
you lose one second on something you do 500 times a day, it makes
nearly ten minutes, and this begins to matter. Using DHTML gives you
response in no time, and this can make a big difference.

Bartek


On 8 March 2010 11:15, Chetan Kumar <chetankumar at vsnl.net> wrote:
> Hi all
> In a form there is a checkbox which if selected should mean that a few
> other fields are not required.
> Is it recommended to add javascript to enable such a functionality? Or
> should this be handled with error message after user saves?
> In a previous discussion adding javascript was discouraged (of course
> that was in the context of saving data which was recommended with save
> button alone).
> http://mail.nexedi.com/pipermail/erp5-dev/2007-March/000951.html
> In my case, creating two forms for selected and not-selected case will
> be an overkill.
> Also, please help with the general approach that should be taken where
> temptation to add javascript is there.
> Regards,
> Chetan
>
> _______________________________________________
> Erp5-users mailing list
> Erp5-users at erp5.org
> http://mail.nexedi.com/mailman/listinfo/erp5-users
>



-- 
"Software is largely a service industry operating under the persistent
but unfounded delusion that it is a manufacturing industry."
Eric S.Raymond, "The Magic Cauldron"



More information about the Erp5-users mailing list