I\'m new to jquery, but I\'m trying to use it to create a multi-step tabbed form.
One one of the pages, I have radio buttons that will show several fields depending on t
var setPaymentDivs = function() {
var selected = $('input[name="paymentmethod"]:checked').val();
$('div.payment').hide();
$('#div' + selected).show();
};
$(function() {
setPaymentDivs();
$('input[name="paymentmethod"]').change(setPaymentDivs);
});
and add class="payment"
to the divs. This abuses the fact that the back button and refresh remember the form values.
Another way is to encode the current state somewhere - in a cookie, in a URL hash... and then extract it on load and set all the values accordingly. Advantage is that it works even if you shut down the browser, and in the case of URL hashes, even if you paste the URL to your friend's browser. (Well, maybe not for payment system :D but you know what I mean)