Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

multi page form html javascript

I want to create a multipage form where only my first page should not display the tab-pill and the remaining pages should have the tabs displaying but without the first page tab in it.

To navigate to the first page only the previous button from the second page should be used.

I am using material bootstrap wizard.

first page of multi page wizard should not have a navigation tab only 2 tabs should be there, previous button still should take you to 1page

Codepen link

$('.wizard-card').bootstrapWizard({
...
// Class dn: display:none
onTabShow:
....
if($current == 1){
                console.log('first tab'); console.log(navigation.parent().addClass('dn'));
                console.log(tab);
            }else{
                navigation.parent().removeClass('dn')
            }
...
//This is the JS code i wrote to hide the navigation bar in the first page

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Using some css , and the onInit, onNext, onPrevious you could reach your need :

First to avoid first tab click set pointer events to none as below :

.wizard-navigation ul li:first-child {
   pointer-events:none;
   visibility:hidden
}

Then you have to hide tabs on wizard initialization :

onInit : function(tab, navigation, index){
      $(".wizard-navigation").hide(); // hiding tab wizard
      //... rest of code 
},

then in onNext show navtabs :

Then you have to hide tabs on wizard initialization :

onNext : function(tab, navigation, index){
      $(".wizard-navigation").show(); // shiing tab wizard
      //... rest of code 
},

then in onPrevious check if index === 0 then hide it again

onPrevious : function(tab, navigation, index){
     if(index === 0) $(".wizard-navigation").hide(); // hiding tab wizard
      //... rest of code 
},

Here is a Pen


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...