Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Apr 2004
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,042
    Thanks
    0
    Thanked 251 Times in 247 Posts
    After the alert statement, call the function that the Next button is calling.

  • #3
    New to the CF scene
    Join Date
    Apr 2004
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,042
    Thanks
    0
    Thanked 251 Times in 247 Posts
    <a href="#" onclick="setImageClicked('1');alert('Correct!');top.frames['nameOfFrameHere'].navigateNext();return false;">


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •