/    Sign up×
Community /Pin to ProfileBookmark

JavaScript does not on Google Chrome

I have used a JS to create a questionnaire and get results of a questionnaire when the button is pressed, but instead i get an alert saying that I need to enable cookie, but cookie are enabled in Chrome. I checked EI and Firefox and it works fine just doesnt like Google.

Here a script

function gradeit(){
var incorrect=null
for (q=1;q<=totalquestions;q++){
var thequestion=eval(“document.myquiz.question”+q)
for (c=0;c<thequestion.length;c++){
if (thequestion[c].checked==true)
actualchoices[q]=thequestion[c].value
}

if (actualchoices[q]!=correctchoices[q]){ //process an incorrect choice
if (incorrect==null)
incorrect=q
else
incorrect+=”/”+q
}
}

if (incorrect==null)
incorrect=”a/b”
document.cookie=’q=’+incorrect
if (document.cookie==”)
alert(“Your browser does not accept cookies. Please adjust your browser settings.”)
else
window.location=”results.htm”
}

function showsolution(){
var win2=window.open(“”,”win2″,”width=200,height=350, scrollbars”)
win2.focus()
win2.document.open()
win2.document.write(‘<title>Solution</title>’)
win2.document.write(‘<body bgcolor=”#FFFFFF”>’)
win2.document.write(‘<center><h3>Solution to Quiz</h3></center>’)
win2.document.write(‘<center><font face=”Arial”>’)
for (i=1;i<=totalquestions;i++){
for (temp=0;temp<incorrect.length;temp++){
if (i==incorrect[temp])
wrong=1
}
if (wrong==1){
win2.document.write(“Question “+i+”=”+correctchoices[i].fontcolor(“red”)+”<br>”)
wrong=0
}
else
win2.document.write(“Question “+i+”=”+correctchoices[i]+”<br>”)
}
win2.document.write(‘</center></font>’)
win2.document.write(“<h5>Note: The solutions in red are the ones to the questions you had incorrectly answered.</h5><p align=’center’><small><a href=’http://www.javascriptkit.com‘ target=’_new’>JavaScript Kit quiz script</a></small>”)
win2.document.close()
}

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @kelics 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.17,
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,
)...