javascript - Progress bar with step answers in a form -
i try make progress bar step when click on next button survey. think missed in actual code. survey composed slider validate answer in output after click button. great if help, !
here html :
<form class="form" name="frm" method="post" action="quest_a_rec.asp" onkeydown="testclavier();" > <input name="id" value="<%=data_questions("id_resultat")%>" type="hidden"> <div class="col-sm-12"> <div class="row col-sm-offset-2"> <div class="col-sm-8 cent" id="question"> <div class="left"> <p class="requestbig"><%=data_questions("libquestion")%></p> </div> <output><%=initoutput%></output> </div> </div> </div> <div class="myslider"> <div class="row col-sm-offset-2"> <div class="col-sm-8 cent"> <div class="col-sm-3" id="jamais"> <p><%=session("liblow")%><br /> |</p> </div> </div> </div> <div class="row col-sm-offset-2"> <div class="col-sm-8 cent"> <input type="range" value="<%=valbornes("valmin")-1%>" step="1" min="<%=valbornes("valmin")%>" max="<%=valbornes("valmax")%>"> <br /> </div> </div> <div class="row col-sm-offset-2"> <div class="col-sm-8 cent"> <div class="col-sm-3" id="toujours"> <p>|<br /> <%=libbornes("libhigh")%></p> </div> </div> </div> </div> </form> <div class="row"> <div class="col-sm-4 col-sm-offset-2"> <p class="avancement"><%=gettextefba("avancement")%></p> </div> <div class="col-sm-5"> <div class="progress"> <div class="progress-bar progress-bar-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100"> </div> </div> </div> <div class="row"> <div class="col-sm-12 boutons"> <div class="col-sm-6 col-sm-push-6"> <button type="button" class="btn mybtnright" href="<%=urlnext%>" onclick="document.frm.submit();" id="btnnext"><%=gettextefba("btn_valider")%><span class="iconinsidebuttonright icon-chevron-right"></span></button> <button type="button" class="action submit btn mybtnright">submit</button> </div> <div class="col-sm-6 col-sm-pull-6"> <button type="button" class="btn mybtnnobs" href="#" role="button" onclick="document.frm_nobs.submit();"><%=gettextefba("btn_nobs")%></button>
here js
$(document).ready(function(){ var current = 1; widget = $(".step"); btnnext = $(".mybtnright"); //btnback = $(".back"); btnsubmit = $(".submit"); // init buttons , ui widget.not(':eq(0)').hide(); hidebuttons(current); setprogress(current); // next button click action btnnext.click(function(){ if(current < widget.length){ // check validation if($(".form").valid()){ widget.show(); widget.not(':eq('+(current++)+')').hide(); setprogress(current); } } hidebuttons(current); }) /* // button click action btnback.click(function(){ if(current > 1){ current = current - 2; if(current < widget.length){ widget.show(); widget.not(':eq('+(current++)+')').hide(); setprogress(current); } } hidebuttons(current); }) */ // submit button click btnsubmit.click(function(){ alert("submit button clicked"); }); $('.form').validate({ // initialize plugin ignore:":not(:visible)", rules: { name : "required" }, }); }); // change progress bar action setprogress = function(currstep){ var percent = parsefloat(100 / widget.length) * currstep; percent = percent.tofixed(); $(".progress-bar").css("width",percent+"%").html(percent+"%"); } // hide buttons according current step hidebuttons = function(current){ var limit = parseint(widget.length); $(".action").hide(); if(current < limit) btnnext.show(); if(current > 1) btnback.show(); if (current == limit) { btnnext.hide(); btnsubmit.show(); } }
Comments
Post a Comment