/    Sign up×
Community /Pin to ProfileBookmark

enable/diable navigation

Hi
I have a quiz that uses javascript to calculate the scores over 10 pages of a template which uses jquery. I’m having trouble disabling the navigation buttons so that the user cannot move on until they submit the question.

The code is in Jquery and Javascript and i’m still learning.

I tried this which worked as it stopped them from navigating away from the page but it stopped my quiz from calculating the score too….

[CODE] //Next Page Function
$(‘.next’).click(function() {
if (current_page == no_pages){
//do nothing
}
else{

if (flag==false)
{
try {
checkAnswer(document.getElementById(‘quizForm’))
flag=true;
return false;
}
catch(err)
{
if (err.number !=-2146823281)
{
alert(err.description);
}
}
}
next_page = (current_page + 1);
$(“#content”).fadeOut(“slow”,function(){
$(“#content”).load(“pages/page_” + next_page + “.html”).fadeIn(‘slow’)}
);
current_page ++;
$(“#current_page”).html(current_page);
progress_bar();
}

});
[/CODE]

This is what the code looks like now without the changes….

[CODE]//Next Page Function
$(‘.next’).click(function() {
if (current_page == no_pages){
//do nothing
}
else{
next_page = (parseInt (current_page) + 1);
$(“#content”).fadeOut(“slow”,function(){
$(“#content”).load(“pages/page_” + next_page + “.html”).fadeIn(‘slow’)}
);
current_page ++;
$(“#current_page”).html(current_page);
progress_bar();
}

});[/CODE]

I was also told to try and disable and then enable the button but i’m not really sure what i’m doing.

I put this bit together but it doesn’t do anything….

[CODE]else{

if (document.getElementById(‘quizForm’)){

if (document.quizForm.cc.disabled==true)

document.quizForm.cc.disabled=false

else

{return true;}
[/CODE]

Any advice would be appreciated.

Thanks

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @katybaby spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.8,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...