Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi all,
Vanilla are planning an update to the site on April 24th (next Wednesday). It is a major PHP8 update which is expected to boost performance across the site. The site will be down from 7pm and it is expected to take about an hour to complete. We appreciate your patience during the update.
Thanks all.

Best method of implementing a wizard using jQuery / Javascript

  • 17-09-2015 11:09pm
    #1
    Registered Users Posts: 5,686 ✭✭✭


    Hello all,

    Just geting familiar with Javascript and jQuery over the last few days. I'm planning on putting together a web page that will include a GUI-like wizard. What would be the best method of implementing something like this?

    Would it be something along the lines of..
    $("nextButton").click( function() {
    $("sectOne").html( ... )
    $("sectTwo").html( ... )
    });

    Am I going about this the wrong way / too literally?


Comments

  • Registered Users Posts: 5,686 ✭✭✭Danger781


    Danger781 wrote: »
    Hello all,

    Just geting familiar with Javascript and jQuery over the last few days. I'm planning on putting together a web page that will include a GUI-like wizard. What would be the best method of implementing something like this?

    Would it be something along the lines of..
    $("nextButton").click( function() {
    $("sectOne").html( ... )
    $("sectTwo").html( ... )
    });

    Am I going about this the wrong way / too literally?

    Looked up some basic wizard examples and some posts on stack overflow. Seems like the best implementation would be dividing the entire form into sections and then using show() and hide() as needed.

    Ill probably go with this method unless someone else has a more intelligent alternative.


  • Registered Users Posts: 6,250 ✭✭✭Buford T Justice


    a bit more information would help, but failing that http://www.jquery-steps.com/


  • Registered Users Posts: 11,977 ✭✭✭✭Giblet


    Use CSS and the :target selector along with anchors, could be a nice JavaScript free alternative. Can animate in CSS as well as use the back button ;)
    <style>
        .step { max-height:0; overflow-y:hidden; opacity:0; transform; transition: opacity .15s ease-in-out  }   
        .step:target {  max-height:100%; overflow-y:visible; opacity:1;  }
    </style>
    <a href="#Step1"> Start Wizard! </a>
    <div id="Step1" class="step">
       <p>This is step 1</p>
       <a href="#Step2">Next</a>
    </div>
    <div id="Step2" class="step">
       <p>This is step 2</p>
       <a href="#Step1">Prev</a>
       <a href="#Step3">Next</a>
    </div>
    <div id="Step3" class="step">
       <p>This is step 3</p>
       <a href="#Step2">Prev</a>
    </div>
    


  • Registered Users Posts: 5,686 ✭✭✭Danger781


    a bit more information would help, but failing that http://www.jquery-steps.com/

    Came across that library alright but I'm doing this as a learning experience - So I'd like to do it all myself. Thanks for the suggestion though!
    Giblet wrote: »
    Use CSS and the :target selector along with anchors, could be a nice JavaScript free alternative. Can animate in CSS as well as use the back button ;)

    Definitely an option, thanks. Like I said above I am doing this more as a learning experience so ideally I would use JS / jQuery but I guess I could try both and decide which implementation I prefer.

    On that note is there any disadvantage to using JS over CSS for something like this? I would imagine 99% of people have Javascript enabled in their web browser nowadays..


  • Registered Users Posts: 5,989 ✭✭✭Talisman


    Take a look at the FormWizard jQuery plugin.

    https://github.com/thecodemine/formwizard


  • Advertisement
Advertisement