Skip to main content
Participating Frequently
September 11, 2009
Answered

Accordion panel switching back to starting page after refresh

  • September 11, 2009
  • 1 reply
  • 699 views

Hello,

I have an accordion widget with two panels. On the first panel is a welcome screen and on the second a user registration form. On this form I have server side validation. If the information entered fails the severside validation, the page refreshes, with the first panel open, which contains the welcome screen. Does anyone know how to keep the current open panel after a page refresh, so the user remians on the second accordion panel, which contains the form?

Any help would be fantastic,

Thank you.

This topic has been closed for replies.
Correct answer David_Powers

The way to link to a specific Spry panel is described in this tutorial on my website: http://foundationphp.com/tutorials/spry_url_utils.php.

The tutorial deals with values pass through the URL, so only the basic principles apply to your scenario. When validating a form server-side, you'll be using the POST method, so you'll need to adapt everything to use conditional logic on the server side like this:

var Accordion1 = new Spry.Widget.Accordion("Accordion1", {defaultPanel: <?php if ($errors) { echo 1; } else { echo 0; } ?>});

1 reply

David_Powers
David_PowersCorrect answer
Inspiring
September 11, 2009

The way to link to a specific Spry panel is described in this tutorial on my website: http://foundationphp.com/tutorials/spry_url_utils.php.

The tutorial deals with values pass through the URL, so only the basic principles apply to your scenario. When validating a form server-side, you'll be using the POST method, so you'll need to adapt everything to use conditional logic on the server side like this:

var Accordion1 = new Spry.Widget.Accordion("Accordion1", {defaultPanel: <?php if ($errors) { echo 1; } else { echo 0; } ?>});

Participating Frequently
September 11, 2009

Hey David,

Thank you once again. As soon as I typed in what you suggested, it worked perfectly. . I only needed to slighty adjust the errors variable for my error array.

Have a good w/end,

Andrew.