Creating multi step forms

后端 未结 3 443
独厮守ぢ
独厮守ぢ 2020-12-04 23:06

I have been searching around for a way to create a multi step form such as: http://planner.builtbybuffalo.com/step-1/

I couldnt find any resources, just other exampl

3条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-04 23:37

    Here you have a full working simple three steps example, with no need to jQuery.

    You just need to define the submit_form() function. The HTML characters « and » just print respectively « and » which might be interesting for the previous and next button characters.

    function shows_form_part(n){
        var i = 1, p = document.getElementById("form_part"+1);
        while (p !== null){
            if (i === n){
                p.style.display = "";
            }
            else{
                p.style.display = "none";
            }
            i++;
            p = document.getElementById("form_part"+i);
        }
    }
    
    function submit_form() {
    	var sum = parseInt(document.getElementById("num1").value) +
                parseInt(document.getElementById("num2").value) +
                parseInt(document.getElementById("num3").value);
      alert("Your result is: " + sum);
    }
    
    
    Part 1

    Part 2

    Part 3

提交回复
热议问题