Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-28-2004, 04:59 AM   PM User | #1
Maya
New to the CF scene

 
Join Date: Apr 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Maya is an unknown quantity at this point
Alert method handling

I have a test with next buttons so the user can go to the next page. I have now added an alert box that displays the correct answer to the test question. The user has to click the OK button to close the alert, and then click the Next button on the same page to proceed, which is irritating. How do I get the user on the next page upon clicking the OK button of the alert box?

This is part of the code in the form:


<TR>
<TD valign=top width=30><A HREF="#" onclick="javascript:setImageClicked('1'); alert('Correct!');"><IMG SRC="../../../images/true.gif" WIDTH="58" HEIGHT="20" BORDER="0" name="img1"></A></TD>
</TR>
<TR>
<TD valign=top><A HREF="#" onclick="javascript:setImageClicked('2'); alert('The correct answer is True.');"><IMG SRC="../../../images/false.gif" WIDTH="58" HEIGHT="20" BORDER="0" name="img2"></a></TD>
</TR>

The onclick is on the True and False buttons.
Thank you for any help.
Maya is offline   Reply With Quote
Old 04-28-2004, 05:03 AM   PM User | #2
glenngv
Supreme Master coder!


 
glenngv's Avatar
 
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
glenngv will become famous soon enough
After the alert statement, call the function that the Next button is calling.
__________________
Glenn
_____________________________________________
Play Tower of Hanoi Android app (Ad-FREE!)
Play Tower of Hanoi Android app (FREE!)
Go to Tower of Hanoi Leaderboard
Play Tower of Hanoi Facebook app
glenngv is offline   Reply With Quote
Old 04-28-2004, 05:49 AM   PM User | #3
Maya
New to the CF scene

 
Join Date: Apr 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Maya is an unknown quantity at this point
I'm in a Frameset, and the Next and Previous buttons are not in the same frame as my test question. The Next button's function sits on a .js page. Could you tell me how to call it? Just inserting function navigateNext(); didn't work. Seeing that it gets called in a different frame, can I override it and push the user to the next page from within my main body frame? Apologies for the inexperience here.

The Next button's code looks like this, fwiw:

function navigateNext()
{
var topicNameLayer='';
var nextPage = "";
var documentLocation = "" + parent.contentFrame.document.location + "";

moduleNoArray = eval("module" + parent.moduleNo + "Array");

moduleNoPos = documentLocation.indexOf("module_");
topicNoPos = documentLocation.indexOf("topic_");
screenNoPos = topicNoPos + 18;

if ((moduleNoPos > -1) && (topicNoPos > -1) && (screenNoPos > -1))
{

moduleNoString = documentLocation.substring((moduleNoPos + 7), (moduleNoPos + 9));
topicNoString = documentLocation.substring((topicNoPos + 6), (topicNoPos + 8));

moduleNo = parseInt(moduleNoString, 10);
topicNo = parseInt(topicNoString, 10);
pageNo = parseInt(documentLocation.substring((screenNoPos), (screenNoPos + 2)), 10);

if (pageNo < moduleNoArray[topicNo][1])
{
pageNo++;

if (pageNo < 10)
{
nextPage = "module_" + moduleNoString + "/topic_" + topicNoString + "/m" + moduleNoString + "_t" + topicNoString + "_p0" + pageNo + ".htm";
}
else
{
nextPage = "module_" + moduleNoString + "/topic_" + topicNoString + "/m" + moduleNoString + "_t" + topicNoString + "_p" + pageNo + ".htm";
}
}
else
{
if ((topicNo + 1) >= moduleNoArray.length)
{
if ((moduleNo + 1) > parent.maxModules)
{
alert("You have reached the last page of this course.");
return;
}
else
{
// Moving to the next module.
moduleNo++;

parent.moduleNo = moduleNo;
moduleNoArray = eval("module" + parent.moduleNo + "Array");

// Updating the list of topics for the next module.
//displayTopics();

topicNo = 0;
pageNo = 1;

parent.currentTopicNo = topicNo;

if (moduleNo < 10)
{
nextPage = "module_0" + moduleNo + "/topic_0" + topicNo + "/m0" + moduleNo + "_t0" + topicNo + "_p0" + pageNo + ".htm";
}
else
{
nextPage = "module_" + moduleNo + "/topic_0" + topicNo + "/m0" + moduleNo + "_t0" + topicNo + "_p0" + pageNo + ".htm";
}


// REMEMBER
//parent.topFrame.topicName.innerHTML = moduleNoArray[topicNo][0];
}
}
else
{
// Moving to the next topic within the current module
topicNo++;
pageNo = 1;
parent.currentTopicNo = topicNo;
if (topicNo < 10)
{
nextPage = "module_" + moduleNoString + "/topic_0" + topicNo + "/m" + moduleNoString + "_t0" + topicNo + "_p0" + pageNo + ".htm";
}
else
{
nextPage = "module_" + moduleNoString + "/topic_" + topicNo + "/m" + moduleNoString + "_t" + topicNo + "_p0" + pageNo + ".htm";
}

// Change the Topic name in the top band
// REMEMBER
//parent.topFrame.topicName.innerHTML = moduleNoArray[topicNo][0];

}

}

// Jump to the next page

parent.contentFrame.document.location = nextPage;
}
}

Thanks for helping.
Maya is offline   Reply With Quote
Old 04-28-2004, 06:20 AM   PM User | #4
glenngv
Supreme Master coder!


 
glenngv's Avatar
 
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
glenngv will become famous soon enough
<a href="#" onclick="setImageClicked('1');alert('Correct!');top.frames['nameOfFrameHere'].navigateNext();return false;">
__________________
Glenn
_____________________________________________
Play Tower of Hanoi Android app (Ad-FREE!)
Play Tower of Hanoi Android app (FREE!)
Go to Tower of Hanoi Leaderboard
Play Tower of Hanoi Facebook app
glenngv is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:12 PM.


Advertisement
Log in to turn off these ads.