On 20-Apr-07, at 6:02 PM, A. Pagaltzis wrote:

* David Cantrell <da...@cantrell.org.uk> [2007-04-20 17:55]:
FWIW, in my own interwebnet applications, I don't use radio
buttons, I have links which the user clicks to immediately
submit their choice to the server.

What you want to do is use single-submit-button forms, not links.
(Eg. you have one <form> for each action rather than a link, with
a submit button as UI to trigger the action.)

You can achieve this in a couple of different ways.

The easiest is probably to use the <button> element, and style it (which works even in Safari, as far as I remember) to make it look like a link. The other option is use AJAX. So you could, on your link:

<a href="/settings/subscribers_only" onclick="magicFunction (this)">Accept messages from Subscribers only</a>

(where magicFunction uses AJAX to do a POST request with some extra bit added to say "this is an ajax request: really do it, and then update the link to say "Accept message from All", or whatever)

The other, arguably nicer, option is to do such a magicFunction on the input element itself. (ie. so when the value is changed just do a silent ajax POST, showing an error message on failure)

Both options could easily work for non-Javascript scenarios (the first by showing a "Do you really want to do this?" form, or whatever; the second by ensuring you can do a traditional full-page submit of the form).

~patrick


Reply via email to