/    Sign up×
Community /Pin to ProfileBookmark

java script quiz..question about answer

I have a question about the answer popup that is written into the easy java script quiz that I located on this site: [URL=http://javascript.internet.com/miscellaneous/javascript-quiz.html]

It allows for five questions and I have figured out how to modify it for the 15 questions that I need, but the answer pop-up doesn’t have a scroll feature or doesn’t expand to show all of the info that I need.

Does anyone know how to add a scroll down feature or even how to change it to default to a page that I can create instead of a pop up?

Thanks for any help…and please…be kind and explanatory as I am very new and learning this by the book and the help button. ?

Thanks again!
Nicole
http://javascript.internet.com/miscellaneous/javascript-quiz.html[/URL]

to post a comment
JavaScript

12 Comments(s)

Copy linkTweet thisAlerts:
@ppseditorauthorMar 09.2004 — sorry about the underlining...no idea where that came from.
Copy linkTweet thisAlerts:
@steelersfan88Mar 09.2004 — instead of using alert(messageTxt), use:[code=php]var newWin = window.open('','_blank',config='height=500,width=200,menubar=no,toolbars=no,status=no,scrollbars=yes')
newWin.document.write(messageTxt)
newWin.focus()
newWin.document.close()[/code]
Copy linkTweet thisAlerts:
@ppseditorauthorMar 09.2004 — Thanks for the help. I have messed around with that a bit and can't quite figure out what to do with what you suggested. Can you provide any further help as to where to put it and what to replace? Thanks. I have yet to change the text.

<!-- Begin

var ans = new Array;

var done = new Array;

var yourAns = new Array;

var explainAnswer = new Array;

var score = 0;

ans[1] = "b";

ans[2] = "c";

ans[3] = "a";

ans[4] = "d";

ans[5] = "b";

ans[6] = "c";

ans[7] = "b";

ans[8] = "d";

ans[9] = "a";

ans[10] = "c";


explainAnswer[1]="The reason why Answer 1 is Blah Blah Blah";

explainAnswer[2]="The reason why Answer 2 is Blah Blah Blah";

explainAnswer[3]="The reason why Answer 3 is Blah Blah Blah";

explainAnswer[4]="The reason why Answer 4 is Blah Blah Blah";

explainAnswer[5]="The reason why Answer 5 is Blah Blah Blah";

explainAnswer[6]="The reason why Answer 1 is Blah Blah Blah";

explainAnswer[7]="The reason why Answer 2 is Blah Blah Blah";

explainAnswer[8]="The reason why Answer 3 is Blah Blah Blah";

explainAnswer[9]="The reason why Answer 4 is Blah Blah Blah";

explainAnswer[10]="The reason why Answer 5 is Blah Blah Blah";


function Engine(question, answer) {

yourAns[question]=answer;

}

function Score(){

var answerText = "How did you do?n------------------------------------n";

for(i=1;i<=15;i++){

answerText=answerText+"nQuestion :"+i+"n";

if(ans[i]!=yourAns[i]){

answerText=answerText+"nThe correct answer was "+ans[i]+"n"+explainAnswer[i]+"n";

}

else{

answerText=answerText+" nCorrect! n";

score++;

}

}



answerText=answerText+"nnYour total score is : "+score+"n";



//now score the user

answerText=answerText+"nComment : ";

if(score<=0){

answerText=answerText+"You need to learn some more";

}

if(score>=1 && score <=2){

answerText=answerText+"bit more practice";

}

if(score>=3 && score <=3){

answerText=answerText+"doing ok";

}

if(score>4){

answerText=answerText+"You are one hot java babe!";

}





alert(answerText);





}

// End -->
Copy linkTweet thisAlerts:
@PittimannMar 09.2004 — Hi!

That would be your script (please note, that I reduced the loop to 10 - you only head 10 examples):
<i>
</i>&lt;script language="JavaScript" type="text/javascript"&gt;
&lt;!--
var ans = new Array;
var done = new Array;
var yourAns = new Array;
var explainAnswer = new Array;
var score = 0;
ans[1] = "b";
ans[2] = "c";
ans[3] = "a";
ans[4] = "d";
ans[5] = "b";
ans[6] = "c";
ans[7] = "b";
ans[8] = "d";
ans[9] = "a";
ans[10] = "c";
explainAnswer[1]="The reason why Answer 1 is Blah Blah Blah";
explainAnswer[2]="The reason why Answer 2 is Blah Blah Blah";
explainAnswer[3]="The reason why Answer 3 is Blah Blah Blah";
explainAnswer[4]="The reason why Answer 4 is Blah Blah Blah";
explainAnswer[5]="The reason why Answer 5 is Blah Blah Blah";
explainAnswer[6]="The reason why Answer 1 is Blah Blah Blah";
explainAnswer[7]="The reason why Answer 2 is Blah Blah Blah";
explainAnswer[8]="The reason why Answer 3 is Blah Blah Blah";
explainAnswer[9]="The reason why Answer 4 is Blah Blah Blah";
explainAnswer[10]="The reason why Answer 5 is Blah Blah Blah";
function Engine(question, answer) {
yourAns[question]=answer;
}
function Score(){
var answerText = "How did you do?n------------------------------------n";
for(i=1;i&lt;=10;i++){
answerText=answerText+"nQuestion :"+i+"n";
if(ans[i]!=yourAns[i]){
answerText=answerText+"nThe correct answer was "+ans[i]+"n"+explainAnswer[i]+"n";
}
else{
answerText=answerText+" nCorrect! n";
score++;
}
}
answerText=answerText+"nnYour total score is : "+score+"n";
//now score the user
answerText=answerText+"nComment : ";
if(score&lt;=0){
answerText=answerText+"You need to learn some more";
}
if(score&gt;=1 &amp;&amp; score &lt;=2){
answerText=answerText+"bit more practice";
}
if(score&gt;=3 &amp;&amp; score &lt;=3){
answerText=answerText+"doing ok";
}
if(score&gt;4){
answerText=answerText+"You are one hot java babe!";
}
[COLOR=red]var newWin = window.open('','_blank',config='height=500,width=400,scrollbars=yes')[/COLOR]
newWin.document.write(answerText)
newWin.focus()
newWin.document.close()
}
//--&gt;
&lt;/script&gt;

In the red line there is a line break after "scro" - please remove it after pasting the code...

Cheers - Pit
Copy linkTweet thisAlerts:
@ppseditorauthorMar 09.2004 — Thank you so much!

I replaced what I had and removed the space in scroll.

Now I get a syntax error and also an error that says "object expected" when the answers are supposed to pop-up. These errors appear one at a time after I click "How did you do?"

Any ideas?

I really appreciate the help.
Copy linkTweet thisAlerts:
@PittimannMar 09.2004 — Hi!

Unfortunately, the software here did not only produce the line break, I mentioned, but in the same line it added a space between "window." and "open" (please eliminate that space as well).

Actually, both Mozilla and IE don't care about that. I recopied and pasted the stuff I posted here into my editor and it works without a problem.

Can you please post the entire code, you are currently using (or a link)?

Cheers - Pit
Copy linkTweet thisAlerts:
@ppseditorauthorMar 09.2004 — Here is the link to the quiz:

After publishing it though, I noticed also that my background is now missing, but only off of that page. I am using fronbt page if that means anything. I know that I am probably making things harder on myself, but I am so new, I am afraid to change. ?


[URL=http://www.parchmentpublishing.com/new_page_49.htm]http://www.parchmentpublishing.com/new_page_49.htm[/URL]

Here is my home page:

[URL=http://www.parchmentpublishing.com/]http://www.parchmentpublishing.com/[/URL]

Thanks so much for helping.

Nicole
Copy linkTweet thisAlerts:
@PittimannMar 09.2004 — Hi!

You just pasted the stuff below an opening script tag - that's all.

In your code, immediately following the opening head tag, you'll just have to remove this:
-----------------


<SCRIPT LANGUAGE="JavaScript">

<!-- This script and many more are available free online at -->

<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
-----------------


Then it should work... ?

(if you want to maintain the JavaScript Source credits, just put them below the script tag which follows the code above).

Cheers - Pit
Copy linkTweet thisAlerts:
@ppseditorauthorMar 09.2004 — Last time I will bother you...promise.

Your suggestion worked great for getting the page to load without the sytax error. But I still get an error when you click on the Well...how did you do? button at the bottom of the quiz.

Any ideas there?

Here is the link again.[URL]http://www.parchmentpublishing.com/new_page_49.htm[/URL]

Thanks so much!!! ?
Copy linkTweet thisAlerts:
@PittimannMar 09.2004 — Hi!

You don't bother me ?...

Unfortunately, you didn't delete everything, I said before. Still one destroying line between the opening head- and the script tag:

<!-- Begin

Simply delete it and there you are...

Cheers - Pit
Copy linkTweet thisAlerts:
@ppseditorauthorMar 09.2004 — You are awesome! Thanks! ?
Copy linkTweet thisAlerts:
@PittimannMar 09.2004 — Hi!

You're welcome!!

Cheers - Pit ?
×

Success!

Help @ppseditor 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.18,
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,
)...