views:

101

answers:

1

I understand that are great plugins for auto-creating multi-part forms but my requirement is pretty simple and basic:

html:

<form action="">
    <fieldset class="step step1">
        fields ...
        <button class="continue">Continue</button>
    </fieldset>
    <fieldset class="step step2">
        fields ...
        <button class="back">Back</button>
        <button class="continue">Continue</button>
    </fieldset>
    <fieldset class="step step3">
        fields ...
        <button class="back">Back</button>
        <button class="submit">Submit</button>
    </fieldset>
</form>

I want to show only one step fieldset at a time and slide (left to right and vice versa) using continue/back buttons.

I'd appreciate any help.

Thanks!

+1  A: 
$('.step1').siblings().hide(); // hide all except step 1

$('.continue').click(function(){
   $(this).closest('.step').hide().next('.step').show();
   return false;
});
$('.back').click(function(){
   $(this).closest('.step').hide().prev('.step').show();
   return false;
});

simple demo

Reigel
Awesome! jQuery makes it look so easy! ;)
Nimbuz
yeah!... save me a lot of time already.. ;)
Reigel