multi-page form with prev and next buttons
Posted: 02 September 2010 03:11 AM   [ Ignore ]
Wallflower
Avatar
Rank
Total Posts:  30
Joined  2010-08-10

We talked about using return parameter with the entry_id redirection in the EE forums: http://expressionengine.com/forums/viewthread/166104/

This works for next buttons, how do you do prev buttons?

I could paginate the form with jQuery accordion, but I would like to save it along the way instead of at the end because it is such a long form. Is this the right approach or does it matter?

Profile
 
 
Posted: 02 September 2010 03:24 AM   [ Ignore ]   [ # 1 ]
Absolute Heartthrob!
Avatar
RankRankRankRankRank
Total Posts:  10369
Joined  2008-09-29

I’d do a prev button in the same way.

 Signature 
Profile
 
 
Posted: 02 September 2010 03:28 AM   [ Ignore ]   [ # 2 ]
Wallflower
Avatar
Rank
Total Posts:  30
Joined  2010-08-10

But the return parameter is specified for the whole form, you can’t have 2.

Profile
 
 
Posted: 02 September 2010 03:53 AM   [ Ignore ]   [ # 3 ]
Absolute Heartthrob!
Avatar
RankRankRankRankRank
Total Posts:  10369
Joined  2008-09-29

I was just thinking of using a straight link.

<a href="{path=form/page_1/{entry_id}">Prev</a

Or something like that. I suppose that the PREV button wouldn’t submit the data though. I knew we’d used PREV buttons somehwere, but when I went to check it out, it had the same limitation.

<a href="{path='client/payment/{segment_3}'}" class="prev_bttn">Previous</a>
<
button id="checkout_next" class="next_bttn">Next</button>

{/exp:cartthrob:checkout_form} 

I suppose you could use jquery to change the return value on the fly when the previous button is pressed. You could have a prev button change the return value, AND submit the form after that. 

<input type="hidden" name="return_url" value="safecracker/ENTRY_ID" />
<
input type="hidden" name="return" value="safecracker/ENTRY_ID" /> 
 Signature 
Profile
 
 
Posted: 03 September 2010 08:32 PM   [ Ignore ]   [ # 4 ]
Wallflower
Avatar
Rank
Total Posts:  30
Joined  2010-08-10

Here’s a jQuery snippet that might help someone out to change the value attributes of the hidden input fields when the previous button is clicked.

$('#prev').click(function() {
            
$("input[name~=return_url]").attr('value''case-evaluation/step6/ENTRY_ID');
            $(
"input[name~=return]").attr('value''case-evaluation/step6/ENTRY_ID');
        
}); 
Profile