[jQuery] Re: Form plugin: Multiple submit buttons

2007-05-16 Thread wyo

On May 15, 3:25 pm, Scott Sauyet <[EMAIL PROTECTED]> wrote:
>
> You could easily do this in JQuery, but then you have to realize that
> the site would not work with Javascript disabled.  Since you are going
> to have to do server-side processing anyway, it doesn't seem that big a
> deal to do the separation.
>
My site has two different kind of users, just visitors and workers.
Workers need to have JS albeit still many functions are usable
without. Visitors shouldn't need JS albeit some functionality already
will be missing. IMO we all are fast approching the point where JS is
a requirement for surfing the web.

Beside I asked once about how to create XMLHttpRequests (calling PHP)
so they could be used by both client and server but since I haven't
gotten any good answers I've lost interest. I definitely won't code
the same function twice.

> But if you really don't mind a complete dependency on JS, something like
> this (untested) code should work:
>
>  $("#button1").click(function() {
>  $(this).parents("form")[0].action = "action1.php";
>  });
>  $("#button2").click(function() {
>  $(this).parents("form")[0].action = "action2.php";
>  });
>
Dependency isn't a problem in my case, thanks. Do I have to care about
if these binds are fired before the form or is this guarantied be
definition?

O. Wyss



[jQuery] Re: Form plugin: Multiple submit buttons

2007-05-15 Thread Mike Alsup


The best way to handle this is to give the submit buttons a name and
value and key off that data on the server tier.

Mike


I've a form with serveral submit buttons which should call quite some
different functions. Is there a way to overwrite the URL depending on
the submit button, calling separate server functions or do I have to
separate them on the server?


[jQuery] Re: Form plugin: Multiple submit buttons

2007-05-15 Thread Scott Sauyet


wyo wrote:

I've a form with serveral submit buttons which should call quite some
different functions. Is there a way to overwrite the URL depending on
the submit button, calling separate server functions or do I have to
separate them on the server?


You could easily do this in JQuery, but then you have to realize that 
the site would not work with Javascript disabled.  Since you are going 
to have to do server-side processing anyway, it doesn't seem that big a 
deal to do the separation.


But if you really don't mind a complete dependency on JS, something like 
this (untested) code should work:


$("#button1").click(function() {
$(this).parents("form")[0].action = "action1.php";
});
$("#button2").click(function() {
$(this).parents("form")[0].action = "action2.php";
});
// ...

Cheers,

  -- Scott