Hi, As I am no expert web programmer I thought I'd better ask the experts if there is a simpler or better solution to my problem than the one I am thinking of. (using TurboGears)
The problem ----------- I have a form. Ok. you can submit, validate it etc. Now I have a link on that form to another page. What I want is that the form gets automatically submitted and validated before the browser follows the link. If the validation has errors the link should not be followed. My solution ----------- 1. client side solution First I thought I just make a little javascript function like this: function xy(url) { document.form.submit(); parent.location=url; } The problem is that submit works ansynchronisly. I do not get a return code to decide if to follow the url or not. Furthermore the form does not get submitted if there is the line parent.location=url; . 2. server side solution I thought of including a hidden field and include directives for my controller method to raise the redirection if no validation errors are there. <a href="#" onClick="xy('/somewhere')"></a> function xy(url) { document.form.hiddenfield.value = "redirect_to: " + url; document.form.submit(); } @expose def mycontroller(self, *args, **kwargs): #do the usual saving stuff if hasattr(kwargs, 'hiddenfield'): #parse the JSON or mini-langage and do the redirection, when no #validation errors As there might be more other directives necessery for client-server communciation I thought of setting the hiddenfield value to JSON or a self made mini-language and parse this in the controller. Is this a good solution? Are there any other options? -- Greg -- http://mail.python.org/mailman/listinfo/python-list