Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MAKE A LINK IN DIFFERENT FOLDERS AND RETURN TO THE ROOT?

Status
Not open for further replies.

melstef

Programmer
Feb 19, 2003
69
0
0
CA
Hello,
I have the same quiz under different folders on the server. I would like to put the quiz only in one folder(name=quiz) so this would be easier for updates.
it goes something like this:
1 - (I click on the quiz page and it goes to #2)

2 - (then I choose between 2 quizzes and it goes to #3)

3- ( when I am done and would like to receive my certificate
I would like to go to #4)

4-

The problem is under #3, the forward to #4 doesn’t work??

Could someone help me please???

this is the code in quiz_basic.htm:
function NextLevel () {
if (score > 10) {
alert("You cheated.");
}
if (score >= 10 && score <= 10) {
self.location="../quizinfo.htm" ---THIS IS THE PROBLEM

}
this is my button:
<input type=button onClick="NextLevel()" value="Receive Your Certificate">

Thanks
 

If the files are all in the same folder, then instead of "../quizinfo.htm", simply use "quizinfo.htm".

Hope this helps,
Dan



 
if not use ../web/quizinfo.htm << changes to root dir then to the web folder!

what you did (../quizinfo.htm) was just make it go up one directory.

Regards,

Martin

Gaming Help And Info:
 
Or

[tt]/web/quizinfo[/tt]

*cLFlaVA
----------------------------
"Holy crip he's a crapple!
 
thanks, but I tried all this before and it's still not working.
On the server I have different folders
web1
web2
web3
web4
web5
In each of those folders I have a page called quizintro.htm and when on click on this it goes to quiz/quiz_basic.htm

This is fine up to here...

Then when I click on the button certificate on the quiz_basic.htm, it gave me an error message "the page cannot be found"

Maybe this will help you guys to understand my problem.
thanks
 
lol -

give us your actual directory structure and the actual code from the button.

*cLFlaVA
----------------------------
"Holy crip he's a crapple!
 
abfco
-quizintro.htm *this is where we choose to go to the quiz
-quizinfo.htm *this is where the person enters their
information to go to the certificate

certificates
-abfco
-juniorcertificate.gif
-mailsubject.txt
-juniorcounter.txt
quiz
-quiz_basic.htm *this is the quiz


you can go to maybe you will understand better with the codes.
thanks
 
The file you're trying to load is NOT in the web folder, it's in the test folder, as you can see here:


So, you'll need to change your code to this:

Code:
self.location="/test/quizinfo.htm"

*cLFlaVA
----------------------------
"Holy crip he's a crapple!
 
As a side note, your code is giving errors in FireFox's JavaScript console.

Additionally, it would be a lot less annoying to the user if you didn't show an alert box on every single click of a radio button. Rather, I would run the score counter when the user clicks "get certificate" and if the user has 10 questions right, bring him/her to the certificate, otherwise, display an alert box.

*cLFlaVA
----------------------------
"Holy crip he's a crapple!
 
the problem is that I can't write: self.location="/test/quizinfo.htm" because the folder name test changes depending on who is going on the site. I would need to put something here: self.location="/???/quizinfo.htm" to go back to the folder the person was into before going to the quiz... I'm starting to thing that this is not possible!!!


As for the quiz itself, that's the way my boss asked me to do it!

thanks
 
You'd have to do a conditional statement within JavaScript.

Code:
var loc = 'quizinfo.htm';
switch ([i]some other variable[/i]) {
  case '[i]one possibility[/i]':
    loc = '/test1/' + loc;
    break;
  case '[i]another possibility[/i]':
    loc = '/test2/' + loc;
    break;
  case '[i]a third possibility[/i]':
    loc = '/test3/' + loc;
    break;
}
self.location = loc;

Where 'some other variable' holds a value that tells you "where the user came from" and the possibilities listed are the values that would drive which folder the user would be taken to.

*cLFlaVA
----------------------------
"Holy crip he's a crapple!
 
Thanks, I will give you feedback on monday for the code.
have a nice weekend
 
Hello,
I'm not very familiar with javascript, usually I take a code and insert it into my .htm file. Usually I understand what it says and does and I can change a few string of the code. You will see above what I did. I'm must be missing something or did not put the code in the right place because my quiz does't work anymore.
Thanks...

<html>
<HEAD>

<script language="JavaScript">
<!--

function SymError()
{
return true;
}

window.onerror = SymError;

//-->
</script>

<SCRIPT LANGUAGE="JavaScript1.1">

<!-- Begin
var ans = new Array;
var done = new Array;
done[1] = false;
done[2] = false;
done[3] = false;
done[4] = false;
done[5] = false;
done[6] = false;
done[7] = false;
done[8] = false;
done[9] = false;
done[10] = false;


var score = 0;
ans[1] = "c";
ans[2] = "a";
ans[3] = "c";
ans[4] = "c";
ans[5] = "c";
ans[6] = "a";
ans[7] = "b";
ans[8] = "d";
ans[9] = "b";
ans[10] = "b";



function Engine(question, answer)
{
if (answer != ans[question])
{
if (done[question] == false)
{
alert("Nope. Your score stays at " + score+" points.");
}
else
{
alert("You have already answered this one.");
document.getElementById("quest"+question+"-"+ans[question]).checked = true;
}
//if(done[question] && )
/*else
{
alert("You have already answered this one.");
}*/
}

else
{
if (done[question] == false)
{
done[question] = true;
score++;
alert("Yes! Your score is now " + score+" points.");
}

else
{
alert("You have already answered this one.");
}
}
}

function NextLevel () {
if (score > 10) {
alert("You cheated.");
}
if (score >= 10 && score <= 10) {
var loc = 'quizinfo.htm';
switch () {
case 'abfco':
loc = '/abfco/' + loc;
break;
case 'test':
loc = '/test/' + loc;
break;
case 'test3':
loc = '/test3/' + loc;
break;
}
self.location = loc;

}
else {
alert("You cannot receive your certificate unless you score "+10+" points.")
}
}
// End -->
</SCRIPT>
<title>Quiz - Junior</title>
<style type="text/css">
<!--
@import url("../fhhweb_body.css");
-->
</style>
<link href="../default.css" rel="stylesheet" type="text/css">
<link href="../fhhweb_body.css" rel="stylesheet" type="text/css">
</head>

 
ok now I found the problem for my quiz. It does work now. the problem is when I click on the button to get the certificate, I have an error page.
When I click the certificate button, it goes here:


Why does it says in the same folder??
 
the switch code doesn't work!!! I probably didn't inserted correctly.. could you help me please...

look at the code posted on nov 22 in this thread..




thanks
 
Could someone help me please, the switch loc doesn't work, what should I do now???
 

You are missing a variable inside the switch statement. You need to insert the name of the variable which you are testing the value of inbetween the brackets.

Hope this helps,
Dan

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top