limcurry87
Guppy
Hi, i've this problem here.. Which i suspect is about IF-Else Statement within another IF-Else Statement in ASP.
Basically when the current page needs to run Chapter1.asp, it couldn't work.
Chapter1.asp(below page) is being link by this current page when the 'init()' function is activated by pressing a button (Start button, next button), the following few lines of codes is shown here:
Start button
function init()
{
objXmlHTTP = new ActiveXObject("Microsoft.XMLHTTP");
objXmlDOM = new ActiveXObject("Microsoft.XMLDOM");
objXmlHTTP.open("POST","Chapter1.asp?Action=Start",false);
objXmlHTTP.send("");
.....
}
Next button
function getNextQ()
{
//update the user's answers list
checkAnswer();
//increment the question no - i.e. to next Question
count++;
url = "Chapter1.asp?Action=NextQ&QNo=" + aQuest[count];
objXmlHTTP.open("POST", url ,false);
objXmlHTTP.send("");
objXmlDOM.loadXML(objXmlHTTP.ResponseText);
//parse the response content fetched from the server
//and display the question
parseQ();
}
- So there is a main IF-ELSEIF statement in Chapter1.asp to check which button was pressed and do something.
But i had added 2 new IF-ELSEIF (1st in brown - to check the session and use the correct XML file..) (2nd in brown - to set different questions for different session pass over, but it is only activated only within the 'Start' in red...)
-----------------------------------------------------
Chapter1.asp
<%
varlevel = Session("level")
varfail = Session("varfail")
set obj = server.createobject("Microsoft.XMLDOM")
obj.async = false
if varlevel = 1 then
obj.load(Server.MapPath("C1L1.xml"))
elseif varlevel = 2
obj.load(Server.MapPath("C1L2.xml"))
elseif varlevel = 3
obj.load(Server.MapPath("C1L3.xml"))
end if
Response.expires = 0
if trim(request("Action")) = "Start" then
Dim TotalQ
TotalQ = obj.selectNodes("data/question").length
Dim aQuest(),temp,isExist,strQ
ReDim aQuest(0) 'to store the question ids
'This below algorithm is for checking whether which tries is he taking now and read out the question.
elseif varfail = 0
response.write strQ
'all further requests - after the first request
elseif trim(request("Action")) = "NextQ" then
temp = "data/question[@id=" & trim(request("QNo")) & "]"
set Node = obj.selectSingleNode(temp)
strXML = "<data>"
strXML = strXML & "<qtext>"
strXML = strXML & Node.selectSingleNode("qtext").text
......
end if
%>
Hope it's not confusing for anyone of you out there reading, and if you have a solution or like to find out more, do reply me .. Thanks alot!
Basically when the current page needs to run Chapter1.asp, it couldn't work.
Chapter1.asp(below page) is being link by this current page when the 'init()' function is activated by pressing a button (Start button, next button), the following few lines of codes is shown here:
Start button
function init()
{
objXmlHTTP = new ActiveXObject("Microsoft.XMLHTTP");
objXmlDOM = new ActiveXObject("Microsoft.XMLDOM");
objXmlHTTP.open("POST","Chapter1.asp?Action=Start",false);
objXmlHTTP.send("");
.....
}
Next button
function getNextQ()
{
//update the user's answers list
checkAnswer();
//increment the question no - i.e. to next Question
count++;
url = "Chapter1.asp?Action=NextQ&QNo=" + aQuest[count];
objXmlHTTP.open("POST", url ,false);
objXmlHTTP.send("");
objXmlDOM.loadXML(objXmlHTTP.ResponseText);
//parse the response content fetched from the server
//and display the question
parseQ();
}
- So there is a main IF-ELSEIF statement in Chapter1.asp to check which button was pressed and do something.
But i had added 2 new IF-ELSEIF (1st in brown - to check the session and use the correct XML file..) (2nd in brown - to set different questions for different session pass over, but it is only activated only within the 'Start' in red...)
-----------------------------------------------------
Chapter1.asp
<%
varlevel = Session("level")
varfail = Session("varfail")
set obj = server.createobject("Microsoft.XMLDOM")
obj.async = false
if varlevel = 1 then
obj.load(Server.MapPath("C1L1.xml"))
elseif varlevel = 2
obj.load(Server.MapPath("C1L2.xml"))
elseif varlevel = 3
obj.load(Server.MapPath("C1L3.xml"))
end if
Response.expires = 0
if trim(request("Action")) = "Start" then
Dim TotalQ
TotalQ = obj.selectNodes("data/question").length
Dim aQuest(),temp,isExist,strQ
ReDim aQuest(0) 'to store the question ids
'This below algorithm is for checking whether which tries is he taking now and read out the question.
elseif varfail = 0
strQ = "1,2"
elseif varfail = 1
strQ = "3,4"
elseif varfail = 2
strQ = "5,6"
end ifelseif varfail = 1
strQ = "3,4"
elseif varfail = 2
strQ = "5,6"
response.write strQ
'all further requests - after the first request
elseif trim(request("Action")) = "NextQ" then
temp = "data/question[@id=" & trim(request("QNo")) & "]"
set Node = obj.selectSingleNode(temp)
strXML = "<data>"
strXML = strXML & "<qtext>"
strXML = strXML & Node.selectSingleNode("qtext").text
......
end if
%>
Hope it's not confusing for anyone of you out there reading, and if you have a solution or like to find out more, do reply me .. Thanks alot!