php - Hide next button for last quiz in quiz application -
i making quiz application using php. right problem last question showing next button shown in image
since questions dynamically fetched db there no pages each question. not able specify @ point should hide next button (what if have 1000 questions). have tried javascript. doesn't quiet seem work.
update source code
demo: http://jsfiddle.net/e4ny6/2/
use
var numquestions, navs; function init() { cd(); numquestions = document.getelementsbyclassname("qbutton").length; navs = document.getelementsbyclassname('navbutton'); show(0); } function show(i) { document.getelementsbyclassname("current")[0].classname="qbutton"; document.getelementsbyclassname("active")[0].classname="qpanel"; document.getelementsbyclassname("qpanel")[i].classname+=" active"; document.getelementsbyclassname("qbutton")[i].classname+=" current"; navs[0].style.display = i===0 ? 'none' : ''; navs[1].style.display = i===numquestions-1 ? 'none' : ''; currentquestion=i; }
... instead of functions init
, show
.
offtopic:
if want improve performance, store document.getelementsbyclassname
calls in variable inside init()
. way expensive calls once.
Comments
Post a Comment