Results 1 to 4 of 4

Thread: computer based training module help

  1. #1
    Join Date
    Apr 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default computer based training module help

    For my javascript class we have to create a functional computer based training module. I've finished most of my content, but I'm having a little trouble. There are 5 modules that you can access from the main page. I need to have it so that the cookies keep track of what page your on in each section. If someone were to leave the site and go back into the section they were on it'll start them on the page that were on when they exited the browser. Can anyone offer me a little help? I'm a big newbie when it comes to javascript

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    I don't usually advise using a pre-built script, but... tried Moodle?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Apr 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    here is a little more information:



    I know I need two cookies one to keep track of the last page that the user has visited and one to flag whether or not this is the first time they've seen the page this session. Im just having syntax problems. Can someone help me fix my code?

    this is the script on the main page:

    Code:
    function setCookies()
    {
    
    var cdRom = document.location="cdrom1.html"
    
    document.cookie = "cdRom="+cdRom+";expires=" + expireDate.toGMTString()
    
    document.location="cdrom1.html"
    
    }
    this is the script on the first page of one of my sections:
    Code:
    expireDate = new Date()
    expireDate.setYear(expireDate.getYear()+1)
    
    function getCookie(Name)
    {
    var search = Name + "="
    var returnvalue = "";
    if (document.cookie.length > 0)
    {
    offset = document.cookie.indexOf(search)
    
    if (offset != -1)
    {
    offset += search.length
    end = document.cookie.indexOf(";", offset);
    if (end == -1) end = document.cookie.length;
    returnvalue=unescape(document.cookie.substring(offset, end))
    }
    }
    return returnvalue;
    }
    
    if(getcookie("track")!="")
    {
    document.location=cdrom1.html
    }
    else
    {
    var stringToSplit=cdRom
    var aryStrings=stringToSplit.split("=")
    document.location=aryStrings
    }
    
    alert(document.cookie)
    
    function setCookies()
    {
    
    var cdRom = document.location="cdrom2.html"
    
    document.cookie="track"
    
    document.cookie = "cdRom="+cdRom+";expires=" + expireDate.toGMTString()
    
    document.location="cdrom2.html"
    
    }
    I'm new to javascript so be gentle

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    This would be better done server-side, as with all cookie-based systems.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

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